mirror of
https://github.com/restic/restic.git
synced 2026-08-16 10:33:17 +00:00
Update dependencies
Among others, this updates minio-go, so that the new "eu-west-3" zone for AWS is supported.
This commit is contained in:
Generated
Vendored
+5
-3
@@ -1,10 +1,10 @@
|
||||
// Copyright 2017, Google Inc. All rights reserved.
|
||||
// Copyright 2018 Google LLC
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
// https://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
@@ -21,6 +21,7 @@ import (
|
||||
)
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strconv"
|
||||
"testing"
|
||||
"time"
|
||||
@@ -31,6 +32,7 @@ import (
|
||||
"google.golang.org/api/option"
|
||||
)
|
||||
|
||||
var _ = fmt.Sprintf
|
||||
var _ = iterator.Done
|
||||
var _ = strconv.FormatUint
|
||||
var _ = time.Now
|
||||
@@ -53,7 +55,7 @@ func TestMetricServiceSmoke(t *testing.T) {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
var formattedName string = MetricProjectPath(projectId)
|
||||
var formattedName string = fmt.Sprintf("projects/%s", projectId)
|
||||
var request = &monitoringpb.ListMonitoredResourceDescriptorsRequest{
|
||||
Name: formattedName,
|
||||
}
|
||||
|
||||
+3
-3
@@ -1,10 +1,10 @@
|
||||
// Copyright 2017, Google Inc. All rights reserved.
|
||||
// Copyright 2018 Google LLC
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
// https://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
@@ -17,7 +17,7 @@
|
||||
// Package monitoring is an auto-generated package for the
|
||||
// Stackdriver Monitoring API.
|
||||
//
|
||||
// NOTE: This package is in alpha. It is not stable, and is likely to be subject to changes.
|
||||
// NOTE: This package is in alpha. It is not stable, and is likely to change.
|
||||
//
|
||||
// Manages your Stackdriver Monitoring data and configurations. Most projects
|
||||
// must be associated with a Stackdriver account, with a few exceptions as
|
||||
|
||||
+11
-29
@@ -1,10 +1,10 @@
|
||||
// Copyright 2017, Google Inc. All rights reserved.
|
||||
// Copyright 2018 Google LLC
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
// https://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
@@ -86,8 +86,8 @@ type GroupClient struct {
|
||||
// The call options for this service.
|
||||
CallOptions *GroupCallOptions
|
||||
|
||||
// The metadata to be sent with each request.
|
||||
Metadata metadata.MD
|
||||
// The x-goog-* metadata to be sent with each request.
|
||||
xGoogMetadata metadata.MD
|
||||
}
|
||||
|
||||
// NewGroupClient creates a new group service client.
|
||||
@@ -136,30 +136,12 @@ func (c *GroupClient) Close() error {
|
||||
func (c *GroupClient) setGoogleClientInfo(keyval ...string) {
|
||||
kv := append([]string{"gl-go", version.Go()}, keyval...)
|
||||
kv = append(kv, "gapic", version.Repo, "gax", gax.Version, "grpc", grpc.Version)
|
||||
c.Metadata = metadata.Pairs("x-goog-api-client", gax.XGoogHeader(kv...))
|
||||
}
|
||||
|
||||
// GroupProjectPath returns the path for the project resource.
|
||||
func GroupProjectPath(project string) string {
|
||||
return "" +
|
||||
"projects/" +
|
||||
project +
|
||||
""
|
||||
}
|
||||
|
||||
// GroupGroupPath returns the path for the group resource.
|
||||
func GroupGroupPath(project, group string) string {
|
||||
return "" +
|
||||
"projects/" +
|
||||
project +
|
||||
"/groups/" +
|
||||
group +
|
||||
""
|
||||
c.xGoogMetadata = metadata.Pairs("x-goog-api-client", gax.XGoogHeader(kv...))
|
||||
}
|
||||
|
||||
// ListGroups lists the existing groups.
|
||||
func (c *GroupClient) ListGroups(ctx context.Context, req *monitoringpb.ListGroupsRequest, opts ...gax.CallOption) *GroupIterator {
|
||||
ctx = insertMetadata(ctx, c.Metadata)
|
||||
ctx = insertMetadata(ctx, c.xGoogMetadata)
|
||||
opts = append(c.CallOptions.ListGroups[0:len(c.CallOptions.ListGroups):len(c.CallOptions.ListGroups)], opts...)
|
||||
it := &GroupIterator{}
|
||||
it.InternalFetch = func(pageSize int, pageToken string) ([]*monitoringpb.Group, string, error) {
|
||||
@@ -194,7 +176,7 @@ func (c *GroupClient) ListGroups(ctx context.Context, req *monitoringpb.ListGrou
|
||||
|
||||
// GetGroup gets a single group.
|
||||
func (c *GroupClient) GetGroup(ctx context.Context, req *monitoringpb.GetGroupRequest, opts ...gax.CallOption) (*monitoringpb.Group, error) {
|
||||
ctx = insertMetadata(ctx, c.Metadata)
|
||||
ctx = insertMetadata(ctx, c.xGoogMetadata)
|
||||
opts = append(c.CallOptions.GetGroup[0:len(c.CallOptions.GetGroup):len(c.CallOptions.GetGroup)], opts...)
|
||||
var resp *monitoringpb.Group
|
||||
err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
|
||||
@@ -210,7 +192,7 @@ func (c *GroupClient) GetGroup(ctx context.Context, req *monitoringpb.GetGroupRe
|
||||
|
||||
// CreateGroup creates a new group.
|
||||
func (c *GroupClient) CreateGroup(ctx context.Context, req *monitoringpb.CreateGroupRequest, opts ...gax.CallOption) (*monitoringpb.Group, error) {
|
||||
ctx = insertMetadata(ctx, c.Metadata)
|
||||
ctx = insertMetadata(ctx, c.xGoogMetadata)
|
||||
opts = append(c.CallOptions.CreateGroup[0:len(c.CallOptions.CreateGroup):len(c.CallOptions.CreateGroup)], opts...)
|
||||
var resp *monitoringpb.Group
|
||||
err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
|
||||
@@ -227,7 +209,7 @@ func (c *GroupClient) CreateGroup(ctx context.Context, req *monitoringpb.CreateG
|
||||
// UpdateGroup updates an existing group.
|
||||
// You can change any group attributes except name.
|
||||
func (c *GroupClient) UpdateGroup(ctx context.Context, req *monitoringpb.UpdateGroupRequest, opts ...gax.CallOption) (*monitoringpb.Group, error) {
|
||||
ctx = insertMetadata(ctx, c.Metadata)
|
||||
ctx = insertMetadata(ctx, c.xGoogMetadata)
|
||||
opts = append(c.CallOptions.UpdateGroup[0:len(c.CallOptions.UpdateGroup):len(c.CallOptions.UpdateGroup)], opts...)
|
||||
var resp *monitoringpb.Group
|
||||
err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
|
||||
@@ -243,7 +225,7 @@ func (c *GroupClient) UpdateGroup(ctx context.Context, req *monitoringpb.UpdateG
|
||||
|
||||
// DeleteGroup deletes an existing group.
|
||||
func (c *GroupClient) DeleteGroup(ctx context.Context, req *monitoringpb.DeleteGroupRequest, opts ...gax.CallOption) error {
|
||||
ctx = insertMetadata(ctx, c.Metadata)
|
||||
ctx = insertMetadata(ctx, c.xGoogMetadata)
|
||||
opts = append(c.CallOptions.DeleteGroup[0:len(c.CallOptions.DeleteGroup):len(c.CallOptions.DeleteGroup)], opts...)
|
||||
err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
|
||||
var err error
|
||||
@@ -255,7 +237,7 @@ func (c *GroupClient) DeleteGroup(ctx context.Context, req *monitoringpb.DeleteG
|
||||
|
||||
// ListGroupMembers lists the monitored resources that are members of a group.
|
||||
func (c *GroupClient) ListGroupMembers(ctx context.Context, req *monitoringpb.ListGroupMembersRequest, opts ...gax.CallOption) *MonitoredResourceIterator {
|
||||
ctx = insertMetadata(ctx, c.Metadata)
|
||||
ctx = insertMetadata(ctx, c.xGoogMetadata)
|
||||
opts = append(c.CallOptions.ListGroupMembers[0:len(c.CallOptions.ListGroupMembers):len(c.CallOptions.ListGroupMembers)], opts...)
|
||||
it := &MonitoredResourceIterator{}
|
||||
it.InternalFetch = func(pageSize int, pageToken string) ([]*monitoredrespb.MonitoredResource, string, error) {
|
||||
|
||||
+8
-8
@@ -1,10 +1,10 @@
|
||||
// Copyright 2017, Google Inc. All rights reserved.
|
||||
// Copyright 2018 Google LLC
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
// https://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
@@ -41,7 +41,7 @@ func ExampleGroupClient_ListGroups() {
|
||||
}
|
||||
|
||||
req := &monitoringpb.ListGroupsRequest{
|
||||
// TODO: Fill request struct fields.
|
||||
// TODO: Fill request struct fields.
|
||||
}
|
||||
it := c.ListGroups(ctx, req)
|
||||
for {
|
||||
@@ -65,7 +65,7 @@ func ExampleGroupClient_GetGroup() {
|
||||
}
|
||||
|
||||
req := &monitoringpb.GetGroupRequest{
|
||||
// TODO: Fill request struct fields.
|
||||
// TODO: Fill request struct fields.
|
||||
}
|
||||
resp, err := c.GetGroup(ctx, req)
|
||||
if err != nil {
|
||||
@@ -83,7 +83,7 @@ func ExampleGroupClient_CreateGroup() {
|
||||
}
|
||||
|
||||
req := &monitoringpb.CreateGroupRequest{
|
||||
// TODO: Fill request struct fields.
|
||||
// TODO: Fill request struct fields.
|
||||
}
|
||||
resp, err := c.CreateGroup(ctx, req)
|
||||
if err != nil {
|
||||
@@ -101,7 +101,7 @@ func ExampleGroupClient_UpdateGroup() {
|
||||
}
|
||||
|
||||
req := &monitoringpb.UpdateGroupRequest{
|
||||
// TODO: Fill request struct fields.
|
||||
// TODO: Fill request struct fields.
|
||||
}
|
||||
resp, err := c.UpdateGroup(ctx, req)
|
||||
if err != nil {
|
||||
@@ -119,7 +119,7 @@ func ExampleGroupClient_DeleteGroup() {
|
||||
}
|
||||
|
||||
req := &monitoringpb.DeleteGroupRequest{
|
||||
// TODO: Fill request struct fields.
|
||||
// TODO: Fill request struct fields.
|
||||
}
|
||||
err = c.DeleteGroup(ctx, req)
|
||||
if err != nil {
|
||||
@@ -135,7 +135,7 @@ func ExampleGroupClient_ListGroupMembers() {
|
||||
}
|
||||
|
||||
req := &monitoringpb.ListGroupMembersRequest{
|
||||
// TODO: Fill request struct fields.
|
||||
// TODO: Fill request struct fields.
|
||||
}
|
||||
it := c.ListGroupMembers(ctx, req)
|
||||
for {
|
||||
|
||||
+13
-41
@@ -1,10 +1,10 @@
|
||||
// Copyright 2017, Google Inc. All rights reserved.
|
||||
// Copyright 2018 Google LLC
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
// https://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
@@ -91,8 +91,8 @@ type MetricClient struct {
|
||||
// The call options for this service.
|
||||
CallOptions *MetricCallOptions
|
||||
|
||||
// The metadata to be sent with each request.
|
||||
Metadata metadata.MD
|
||||
// The x-goog-* metadata to be sent with each request.
|
||||
xGoogMetadata metadata.MD
|
||||
}
|
||||
|
||||
// NewMetricClient creates a new metric service client.
|
||||
@@ -131,40 +131,12 @@ func (c *MetricClient) Close() error {
|
||||
func (c *MetricClient) setGoogleClientInfo(keyval ...string) {
|
||||
kv := append([]string{"gl-go", version.Go()}, keyval...)
|
||||
kv = append(kv, "gapic", version.Repo, "gax", gax.Version, "grpc", grpc.Version)
|
||||
c.Metadata = metadata.Pairs("x-goog-api-client", gax.XGoogHeader(kv...))
|
||||
}
|
||||
|
||||
// MetricProjectPath returns the path for the project resource.
|
||||
func MetricProjectPath(project string) string {
|
||||
return "" +
|
||||
"projects/" +
|
||||
project +
|
||||
""
|
||||
}
|
||||
|
||||
// MetricMetricDescriptorPath returns the path for the metric descriptor resource.
|
||||
func MetricMetricDescriptorPath(project, metricDescriptor string) string {
|
||||
return "" +
|
||||
"projects/" +
|
||||
project +
|
||||
"/metricDescriptors/" +
|
||||
metricDescriptor +
|
||||
""
|
||||
}
|
||||
|
||||
// MetricMonitoredResourceDescriptorPath returns the path for the monitored resource descriptor resource.
|
||||
func MetricMonitoredResourceDescriptorPath(project, monitoredResourceDescriptor string) string {
|
||||
return "" +
|
||||
"projects/" +
|
||||
project +
|
||||
"/monitoredResourceDescriptors/" +
|
||||
monitoredResourceDescriptor +
|
||||
""
|
||||
c.xGoogMetadata = metadata.Pairs("x-goog-api-client", gax.XGoogHeader(kv...))
|
||||
}
|
||||
|
||||
// ListMonitoredResourceDescriptors lists monitored resource descriptors that match a filter. This method does not require a Stackdriver account.
|
||||
func (c *MetricClient) ListMonitoredResourceDescriptors(ctx context.Context, req *monitoringpb.ListMonitoredResourceDescriptorsRequest, opts ...gax.CallOption) *MonitoredResourceDescriptorIterator {
|
||||
ctx = insertMetadata(ctx, c.Metadata)
|
||||
ctx = insertMetadata(ctx, c.xGoogMetadata)
|
||||
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) {
|
||||
@@ -199,7 +171,7 @@ func (c *MetricClient) ListMonitoredResourceDescriptors(ctx context.Context, req
|
||||
|
||||
// GetMonitoredResourceDescriptor gets a single monitored resource descriptor. This method does not require a Stackdriver account.
|
||||
func (c *MetricClient) GetMonitoredResourceDescriptor(ctx context.Context, req *monitoringpb.GetMonitoredResourceDescriptorRequest, opts ...gax.CallOption) (*monitoredrespb.MonitoredResourceDescriptor, error) {
|
||||
ctx = insertMetadata(ctx, c.Metadata)
|
||||
ctx = insertMetadata(ctx, c.xGoogMetadata)
|
||||
opts = append(c.CallOptions.GetMonitoredResourceDescriptor[0:len(c.CallOptions.GetMonitoredResourceDescriptor):len(c.CallOptions.GetMonitoredResourceDescriptor)], opts...)
|
||||
var resp *monitoredrespb.MonitoredResourceDescriptor
|
||||
err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
|
||||
@@ -215,7 +187,7 @@ func (c *MetricClient) GetMonitoredResourceDescriptor(ctx context.Context, req *
|
||||
|
||||
// ListMetricDescriptors lists metric descriptors that match a filter. This method does not require a Stackdriver account.
|
||||
func (c *MetricClient) ListMetricDescriptors(ctx context.Context, req *monitoringpb.ListMetricDescriptorsRequest, opts ...gax.CallOption) *MetricDescriptorIterator {
|
||||
ctx = insertMetadata(ctx, c.Metadata)
|
||||
ctx = insertMetadata(ctx, c.xGoogMetadata)
|
||||
opts = append(c.CallOptions.ListMetricDescriptors[0:len(c.CallOptions.ListMetricDescriptors):len(c.CallOptions.ListMetricDescriptors)], opts...)
|
||||
it := &MetricDescriptorIterator{}
|
||||
it.InternalFetch = func(pageSize int, pageToken string) ([]*metricpb.MetricDescriptor, string, error) {
|
||||
@@ -250,7 +222,7 @@ func (c *MetricClient) ListMetricDescriptors(ctx context.Context, req *monitorin
|
||||
|
||||
// GetMetricDescriptor gets a single metric descriptor. This method does not require a Stackdriver account.
|
||||
func (c *MetricClient) GetMetricDescriptor(ctx context.Context, req *monitoringpb.GetMetricDescriptorRequest, opts ...gax.CallOption) (*metricpb.MetricDescriptor, error) {
|
||||
ctx = insertMetadata(ctx, c.Metadata)
|
||||
ctx = insertMetadata(ctx, c.xGoogMetadata)
|
||||
opts = append(c.CallOptions.GetMetricDescriptor[0:len(c.CallOptions.GetMetricDescriptor):len(c.CallOptions.GetMetricDescriptor)], opts...)
|
||||
var resp *metricpb.MetricDescriptor
|
||||
err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
|
||||
@@ -268,7 +240,7 @@ func (c *MetricClient) GetMetricDescriptor(ctx context.Context, req *monitoringp
|
||||
// User-created metric descriptors define
|
||||
// custom metrics (at /monitoring/custom-metrics).
|
||||
func (c *MetricClient) CreateMetricDescriptor(ctx context.Context, req *monitoringpb.CreateMetricDescriptorRequest, opts ...gax.CallOption) (*metricpb.MetricDescriptor, error) {
|
||||
ctx = insertMetadata(ctx, c.Metadata)
|
||||
ctx = insertMetadata(ctx, c.xGoogMetadata)
|
||||
opts = append(c.CallOptions.CreateMetricDescriptor[0:len(c.CallOptions.CreateMetricDescriptor):len(c.CallOptions.CreateMetricDescriptor)], opts...)
|
||||
var resp *metricpb.MetricDescriptor
|
||||
err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
|
||||
@@ -285,7 +257,7 @@ func (c *MetricClient) CreateMetricDescriptor(ctx context.Context, req *monitori
|
||||
// DeleteMetricDescriptor deletes a metric descriptor. Only user-created
|
||||
// custom metrics (at /monitoring/custom-metrics) can be deleted.
|
||||
func (c *MetricClient) DeleteMetricDescriptor(ctx context.Context, req *monitoringpb.DeleteMetricDescriptorRequest, opts ...gax.CallOption) error {
|
||||
ctx = insertMetadata(ctx, c.Metadata)
|
||||
ctx = insertMetadata(ctx, c.xGoogMetadata)
|
||||
opts = append(c.CallOptions.DeleteMetricDescriptor[0:len(c.CallOptions.DeleteMetricDescriptor):len(c.CallOptions.DeleteMetricDescriptor)], opts...)
|
||||
err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
|
||||
var err error
|
||||
@@ -297,7 +269,7 @@ func (c *MetricClient) DeleteMetricDescriptor(ctx context.Context, req *monitori
|
||||
|
||||
// ListTimeSeries lists time series that match a filter. This method does not require a Stackdriver account.
|
||||
func (c *MetricClient) ListTimeSeries(ctx context.Context, req *monitoringpb.ListTimeSeriesRequest, opts ...gax.CallOption) *TimeSeriesIterator {
|
||||
ctx = insertMetadata(ctx, c.Metadata)
|
||||
ctx = insertMetadata(ctx, c.xGoogMetadata)
|
||||
opts = append(c.CallOptions.ListTimeSeries[0:len(c.CallOptions.ListTimeSeries):len(c.CallOptions.ListTimeSeries)], opts...)
|
||||
it := &TimeSeriesIterator{}
|
||||
it.InternalFetch = func(pageSize int, pageToken string) ([]*monitoringpb.TimeSeries, string, error) {
|
||||
@@ -335,7 +307,7 @@ func (c *MetricClient) ListTimeSeries(ctx context.Context, req *monitoringpb.Lis
|
||||
// If any time series could not be written, a corresponding failure message is
|
||||
// included in the error response.
|
||||
func (c *MetricClient) CreateTimeSeries(ctx context.Context, req *monitoringpb.CreateTimeSeriesRequest, opts ...gax.CallOption) error {
|
||||
ctx = insertMetadata(ctx, c.Metadata)
|
||||
ctx = insertMetadata(ctx, c.xGoogMetadata)
|
||||
opts = append(c.CallOptions.CreateTimeSeries[0:len(c.CallOptions.CreateTimeSeries):len(c.CallOptions.CreateTimeSeries)], opts...)
|
||||
err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
|
||||
var err error
|
||||
|
||||
+10
-10
@@ -1,10 +1,10 @@
|
||||
// Copyright 2017, Google Inc. All rights reserved.
|
||||
// Copyright 2018 Google LLC
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
// https://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
@@ -41,7 +41,7 @@ func ExampleMetricClient_ListMonitoredResourceDescriptors() {
|
||||
}
|
||||
|
||||
req := &monitoringpb.ListMonitoredResourceDescriptorsRequest{
|
||||
// TODO: Fill request struct fields.
|
||||
// TODO: Fill request struct fields.
|
||||
}
|
||||
it := c.ListMonitoredResourceDescriptors(ctx, req)
|
||||
for {
|
||||
@@ -65,7 +65,7 @@ func ExampleMetricClient_GetMonitoredResourceDescriptor() {
|
||||
}
|
||||
|
||||
req := &monitoringpb.GetMonitoredResourceDescriptorRequest{
|
||||
// TODO: Fill request struct fields.
|
||||
// TODO: Fill request struct fields.
|
||||
}
|
||||
resp, err := c.GetMonitoredResourceDescriptor(ctx, req)
|
||||
if err != nil {
|
||||
@@ -83,7 +83,7 @@ func ExampleMetricClient_ListMetricDescriptors() {
|
||||
}
|
||||
|
||||
req := &monitoringpb.ListMetricDescriptorsRequest{
|
||||
// TODO: Fill request struct fields.
|
||||
// TODO: Fill request struct fields.
|
||||
}
|
||||
it := c.ListMetricDescriptors(ctx, req)
|
||||
for {
|
||||
@@ -107,7 +107,7 @@ func ExampleMetricClient_GetMetricDescriptor() {
|
||||
}
|
||||
|
||||
req := &monitoringpb.GetMetricDescriptorRequest{
|
||||
// TODO: Fill request struct fields.
|
||||
// TODO: Fill request struct fields.
|
||||
}
|
||||
resp, err := c.GetMetricDescriptor(ctx, req)
|
||||
if err != nil {
|
||||
@@ -125,7 +125,7 @@ func ExampleMetricClient_CreateMetricDescriptor() {
|
||||
}
|
||||
|
||||
req := &monitoringpb.CreateMetricDescriptorRequest{
|
||||
// TODO: Fill request struct fields.
|
||||
// TODO: Fill request struct fields.
|
||||
}
|
||||
resp, err := c.CreateMetricDescriptor(ctx, req)
|
||||
if err != nil {
|
||||
@@ -143,7 +143,7 @@ func ExampleMetricClient_DeleteMetricDescriptor() {
|
||||
}
|
||||
|
||||
req := &monitoringpb.DeleteMetricDescriptorRequest{
|
||||
// TODO: Fill request struct fields.
|
||||
// TODO: Fill request struct fields.
|
||||
}
|
||||
err = c.DeleteMetricDescriptor(ctx, req)
|
||||
if err != nil {
|
||||
@@ -159,7 +159,7 @@ func ExampleMetricClient_ListTimeSeries() {
|
||||
}
|
||||
|
||||
req := &monitoringpb.ListTimeSeriesRequest{
|
||||
// TODO: Fill request struct fields.
|
||||
// TODO: Fill request struct fields.
|
||||
}
|
||||
it := c.ListTimeSeries(ctx, req)
|
||||
for {
|
||||
@@ -183,7 +183,7 @@ func ExampleMetricClient_CreateTimeSeries() {
|
||||
}
|
||||
|
||||
req := &monitoringpb.CreateTimeSeriesRequest{
|
||||
// TODO: Fill request struct fields.
|
||||
// TODO: Fill request struct fields.
|
||||
}
|
||||
err = c.CreateTimeSeries(ctx, req)
|
||||
if err != nil {
|
||||
|
||||
+497
-31
@@ -1,10 +1,10 @@
|
||||
// Copyright 2017, Google Inc. All rights reserved.
|
||||
// Copyright 2018 Google LLC
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
// https://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
@@ -246,13 +246,101 @@ func (s *mockMetricServer) CreateTimeSeries(ctx context.Context, req *monitoring
|
||||
return s.resps[0].(*emptypb.Empty), nil
|
||||
}
|
||||
|
||||
type mockUptimeCheckServer struct {
|
||||
// Embed for forward compatibility.
|
||||
// Tests will keep working if more methods are added
|
||||
// in the future.
|
||||
monitoringpb.UptimeCheckServiceServer
|
||||
|
||||
reqs []proto.Message
|
||||
|
||||
// If set, all calls return this error.
|
||||
err error
|
||||
|
||||
// responses to return if err == nil
|
||||
resps []proto.Message
|
||||
}
|
||||
|
||||
func (s *mockUptimeCheckServer) ListUptimeCheckConfigs(ctx context.Context, req *monitoringpb.ListUptimeCheckConfigsRequest) (*monitoringpb.ListUptimeCheckConfigsResponse, 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].(*monitoringpb.ListUptimeCheckConfigsResponse), nil
|
||||
}
|
||||
|
||||
func (s *mockUptimeCheckServer) GetUptimeCheckConfig(ctx context.Context, req *monitoringpb.GetUptimeCheckConfigRequest) (*monitoringpb.UptimeCheckConfig, 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].(*monitoringpb.UptimeCheckConfig), nil
|
||||
}
|
||||
|
||||
func (s *mockUptimeCheckServer) CreateUptimeCheckConfig(ctx context.Context, req *monitoringpb.CreateUptimeCheckConfigRequest) (*monitoringpb.UptimeCheckConfig, 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].(*monitoringpb.UptimeCheckConfig), nil
|
||||
}
|
||||
|
||||
func (s *mockUptimeCheckServer) UpdateUptimeCheckConfig(ctx context.Context, req *monitoringpb.UpdateUptimeCheckConfigRequest) (*monitoringpb.UptimeCheckConfig, 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].(*monitoringpb.UptimeCheckConfig), nil
|
||||
}
|
||||
|
||||
func (s *mockUptimeCheckServer) DeleteUptimeCheckConfig(ctx context.Context, req *monitoringpb.DeleteUptimeCheckConfigRequest) (*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 *mockUptimeCheckServer) ListUptimeCheckIps(ctx context.Context, req *monitoringpb.ListUptimeCheckIpsRequest) (*monitoringpb.ListUptimeCheckIpsResponse, 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].(*monitoringpb.ListUptimeCheckIpsResponse), nil
|
||||
}
|
||||
|
||||
// clientOpt is the option tests should use to connect to the test server.
|
||||
// It is initialized by TestMain.
|
||||
var clientOpt option.ClientOption
|
||||
|
||||
var (
|
||||
mockGroup mockGroupServer
|
||||
mockMetric mockMetricServer
|
||||
mockGroup mockGroupServer
|
||||
mockMetric mockMetricServer
|
||||
mockUptimeCheck mockUptimeCheckServer
|
||||
)
|
||||
|
||||
func TestMain(m *testing.M) {
|
||||
@@ -261,6 +349,7 @@ func TestMain(m *testing.M) {
|
||||
serv := grpc.NewServer()
|
||||
monitoringpb.RegisterGroupServiceServer(serv, &mockGroup)
|
||||
monitoringpb.RegisterMetricServiceServer(serv, &mockMetric)
|
||||
monitoringpb.RegisterUptimeCheckServiceServer(serv, &mockUptimeCheck)
|
||||
|
||||
lis, err := net.Listen("tcp", "localhost:0")
|
||||
if err != nil {
|
||||
@@ -291,7 +380,7 @@ func TestGroupServiceListGroups(t *testing.T) {
|
||||
|
||||
mockGroup.resps = append(mockGroup.resps[:0], expectedResponse)
|
||||
|
||||
var formattedName string = GroupProjectPath("[PROJECT]")
|
||||
var formattedName string = fmt.Sprintf("projects/%s", "[PROJECT]")
|
||||
var request = &monitoringpb.ListGroupsRequest{
|
||||
Name: formattedName,
|
||||
}
|
||||
@@ -330,7 +419,7 @@ func TestGroupServiceListGroupsError(t *testing.T) {
|
||||
errCode := codes.PermissionDenied
|
||||
mockGroup.err = gstatus.Error(errCode, "test error")
|
||||
|
||||
var formattedName string = GroupProjectPath("[PROJECT]")
|
||||
var formattedName string = fmt.Sprintf("projects/%s", "[PROJECT]")
|
||||
var request = &monitoringpb.ListGroupsRequest{
|
||||
Name: formattedName,
|
||||
}
|
||||
@@ -368,7 +457,7 @@ func TestGroupServiceGetGroup(t *testing.T) {
|
||||
|
||||
mockGroup.resps = append(mockGroup.resps[:0], expectedResponse)
|
||||
|
||||
var formattedName string = GroupGroupPath("[PROJECT]", "[GROUP]")
|
||||
var formattedName string = fmt.Sprintf("projects/%s/groups/%s", "[PROJECT]", "[GROUP]")
|
||||
var request = &monitoringpb.GetGroupRequest{
|
||||
Name: formattedName,
|
||||
}
|
||||
@@ -397,7 +486,7 @@ func TestGroupServiceGetGroupError(t *testing.T) {
|
||||
errCode := codes.PermissionDenied
|
||||
mockGroup.err = gstatus.Error(errCode, "test error")
|
||||
|
||||
var formattedName string = GroupGroupPath("[PROJECT]", "[GROUP]")
|
||||
var formattedName string = fmt.Sprintf("projects/%s/groups/%s", "[PROJECT]", "[GROUP]")
|
||||
var request = &monitoringpb.GetGroupRequest{
|
||||
Name: formattedName,
|
||||
}
|
||||
@@ -435,7 +524,7 @@ func TestGroupServiceCreateGroup(t *testing.T) {
|
||||
|
||||
mockGroup.resps = append(mockGroup.resps[:0], expectedResponse)
|
||||
|
||||
var formattedName string = GroupProjectPath("[PROJECT]")
|
||||
var formattedName string = fmt.Sprintf("projects/%s", "[PROJECT]")
|
||||
var group *monitoringpb.Group = &monitoringpb.Group{}
|
||||
var request = &monitoringpb.CreateGroupRequest{
|
||||
Name: formattedName,
|
||||
@@ -466,7 +555,7 @@ func TestGroupServiceCreateGroupError(t *testing.T) {
|
||||
errCode := codes.PermissionDenied
|
||||
mockGroup.err = gstatus.Error(errCode, "test error")
|
||||
|
||||
var formattedName string = GroupProjectPath("[PROJECT]")
|
||||
var formattedName string = fmt.Sprintf("projects/%s", "[PROJECT]")
|
||||
var group *monitoringpb.Group = &monitoringpb.Group{}
|
||||
var request = &monitoringpb.CreateGroupRequest{
|
||||
Name: formattedName,
|
||||
@@ -562,7 +651,7 @@ func TestGroupServiceDeleteGroup(t *testing.T) {
|
||||
|
||||
mockGroup.resps = append(mockGroup.resps[:0], expectedResponse)
|
||||
|
||||
var formattedName string = GroupGroupPath("[PROJECT]", "[GROUP]")
|
||||
var formattedName string = fmt.Sprintf("projects/%s/groups/%s", "[PROJECT]", "[GROUP]")
|
||||
var request = &monitoringpb.DeleteGroupRequest{
|
||||
Name: formattedName,
|
||||
}
|
||||
@@ -588,7 +677,7 @@ func TestGroupServiceDeleteGroupError(t *testing.T) {
|
||||
errCode := codes.PermissionDenied
|
||||
mockGroup.err = gstatus.Error(errCode, "test error")
|
||||
|
||||
var formattedName string = GroupGroupPath("[PROJECT]", "[GROUP]")
|
||||
var formattedName string = fmt.Sprintf("projects/%s/groups/%s", "[PROJECT]", "[GROUP]")
|
||||
var request = &monitoringpb.DeleteGroupRequest{
|
||||
Name: formattedName,
|
||||
}
|
||||
@@ -608,7 +697,7 @@ func TestGroupServiceDeleteGroupError(t *testing.T) {
|
||||
}
|
||||
func TestGroupServiceListGroupMembers(t *testing.T) {
|
||||
var nextPageToken string = ""
|
||||
var totalSize int32 = -705419236
|
||||
var totalSize int32 = 705419236
|
||||
var membersElement *monitoredrespb.MonitoredResource = &monitoredrespb.MonitoredResource{}
|
||||
var members = []*monitoredrespb.MonitoredResource{membersElement}
|
||||
var expectedResponse = &monitoringpb.ListGroupMembersResponse{
|
||||
@@ -622,7 +711,7 @@ func TestGroupServiceListGroupMembers(t *testing.T) {
|
||||
|
||||
mockGroup.resps = append(mockGroup.resps[:0], expectedResponse)
|
||||
|
||||
var formattedName string = GroupGroupPath("[PROJECT]", "[GROUP]")
|
||||
var formattedName string = fmt.Sprintf("projects/%s/groups/%s", "[PROJECT]", "[GROUP]")
|
||||
var request = &monitoringpb.ListGroupMembersRequest{
|
||||
Name: formattedName,
|
||||
}
|
||||
@@ -661,7 +750,7 @@ func TestGroupServiceListGroupMembersError(t *testing.T) {
|
||||
errCode := codes.PermissionDenied
|
||||
mockGroup.err = gstatus.Error(errCode, "test error")
|
||||
|
||||
var formattedName string = GroupGroupPath("[PROJECT]", "[GROUP]")
|
||||
var formattedName string = fmt.Sprintf("projects/%s/groups/%s", "[PROJECT]", "[GROUP]")
|
||||
var request = &monitoringpb.ListGroupMembersRequest{
|
||||
Name: formattedName,
|
||||
}
|
||||
@@ -694,7 +783,7 @@ func TestMetricServiceListMonitoredResourceDescriptors(t *testing.T) {
|
||||
|
||||
mockMetric.resps = append(mockMetric.resps[:0], expectedResponse)
|
||||
|
||||
var formattedName string = MetricProjectPath("[PROJECT]")
|
||||
var formattedName string = fmt.Sprintf("projects/%s", "[PROJECT]")
|
||||
var request = &monitoringpb.ListMonitoredResourceDescriptorsRequest{
|
||||
Name: formattedName,
|
||||
}
|
||||
@@ -733,7 +822,7 @@ func TestMetricServiceListMonitoredResourceDescriptorsError(t *testing.T) {
|
||||
errCode := codes.PermissionDenied
|
||||
mockMetric.err = gstatus.Error(errCode, "test error")
|
||||
|
||||
var formattedName string = MetricProjectPath("[PROJECT]")
|
||||
var formattedName string = fmt.Sprintf("projects/%s", "[PROJECT]")
|
||||
var request = &monitoringpb.ListMonitoredResourceDescriptorsRequest{
|
||||
Name: formattedName,
|
||||
}
|
||||
@@ -769,7 +858,7 @@ func TestMetricServiceGetMonitoredResourceDescriptor(t *testing.T) {
|
||||
|
||||
mockMetric.resps = append(mockMetric.resps[:0], expectedResponse)
|
||||
|
||||
var formattedName string = MetricMonitoredResourceDescriptorPath("[PROJECT]", "[MONITORED_RESOURCE_DESCRIPTOR]")
|
||||
var formattedName string = fmt.Sprintf("projects/%s/monitoredResourceDescriptors/%s", "[PROJECT]", "[MONITORED_RESOURCE_DESCRIPTOR]")
|
||||
var request = &monitoringpb.GetMonitoredResourceDescriptorRequest{
|
||||
Name: formattedName,
|
||||
}
|
||||
@@ -798,7 +887,7 @@ func TestMetricServiceGetMonitoredResourceDescriptorError(t *testing.T) {
|
||||
errCode := codes.PermissionDenied
|
||||
mockMetric.err = gstatus.Error(errCode, "test error")
|
||||
|
||||
var formattedName string = MetricMonitoredResourceDescriptorPath("[PROJECT]", "[MONITORED_RESOURCE_DESCRIPTOR]")
|
||||
var formattedName string = fmt.Sprintf("projects/%s/monitoredResourceDescriptors/%s", "[PROJECT]", "[MONITORED_RESOURCE_DESCRIPTOR]")
|
||||
var request = &monitoringpb.GetMonitoredResourceDescriptorRequest{
|
||||
Name: formattedName,
|
||||
}
|
||||
@@ -831,7 +920,7 @@ func TestMetricServiceListMetricDescriptors(t *testing.T) {
|
||||
|
||||
mockMetric.resps = append(mockMetric.resps[:0], expectedResponse)
|
||||
|
||||
var formattedName string = MetricProjectPath("[PROJECT]")
|
||||
var formattedName string = fmt.Sprintf("projects/%s", "[PROJECT]")
|
||||
var request = &monitoringpb.ListMetricDescriptorsRequest{
|
||||
Name: formattedName,
|
||||
}
|
||||
@@ -870,7 +959,7 @@ func TestMetricServiceListMetricDescriptorsError(t *testing.T) {
|
||||
errCode := codes.PermissionDenied
|
||||
mockMetric.err = gstatus.Error(errCode, "test error")
|
||||
|
||||
var formattedName string = MetricProjectPath("[PROJECT]")
|
||||
var formattedName string = fmt.Sprintf("projects/%s", "[PROJECT]")
|
||||
var request = &monitoringpb.ListMetricDescriptorsRequest{
|
||||
Name: formattedName,
|
||||
}
|
||||
@@ -908,7 +997,7 @@ func TestMetricServiceGetMetricDescriptor(t *testing.T) {
|
||||
|
||||
mockMetric.resps = append(mockMetric.resps[:0], expectedResponse)
|
||||
|
||||
var formattedName string = MetricMetricDescriptorPath("[PROJECT]", "[METRIC_DESCRIPTOR]")
|
||||
var formattedName string = fmt.Sprintf("projects/%s/metricDescriptors/%s", "[PROJECT]", "[METRIC_DESCRIPTOR]")
|
||||
var request = &monitoringpb.GetMetricDescriptorRequest{
|
||||
Name: formattedName,
|
||||
}
|
||||
@@ -937,7 +1026,7 @@ func TestMetricServiceGetMetricDescriptorError(t *testing.T) {
|
||||
errCode := codes.PermissionDenied
|
||||
mockMetric.err = gstatus.Error(errCode, "test error")
|
||||
|
||||
var formattedName string = MetricMetricDescriptorPath("[PROJECT]", "[METRIC_DESCRIPTOR]")
|
||||
var formattedName string = fmt.Sprintf("projects/%s/metricDescriptors/%s", "[PROJECT]", "[METRIC_DESCRIPTOR]")
|
||||
var request = &monitoringpb.GetMetricDescriptorRequest{
|
||||
Name: formattedName,
|
||||
}
|
||||
@@ -975,7 +1064,7 @@ func TestMetricServiceCreateMetricDescriptor(t *testing.T) {
|
||||
|
||||
mockMetric.resps = append(mockMetric.resps[:0], expectedResponse)
|
||||
|
||||
var formattedName string = MetricProjectPath("[PROJECT]")
|
||||
var formattedName string = fmt.Sprintf("projects/%s", "[PROJECT]")
|
||||
var metricDescriptor *metricpb.MetricDescriptor = &metricpb.MetricDescriptor{}
|
||||
var request = &monitoringpb.CreateMetricDescriptorRequest{
|
||||
Name: formattedName,
|
||||
@@ -1006,7 +1095,7 @@ func TestMetricServiceCreateMetricDescriptorError(t *testing.T) {
|
||||
errCode := codes.PermissionDenied
|
||||
mockMetric.err = gstatus.Error(errCode, "test error")
|
||||
|
||||
var formattedName string = MetricProjectPath("[PROJECT]")
|
||||
var formattedName string = fmt.Sprintf("projects/%s", "[PROJECT]")
|
||||
var metricDescriptor *metricpb.MetricDescriptor = &metricpb.MetricDescriptor{}
|
||||
var request = &monitoringpb.CreateMetricDescriptorRequest{
|
||||
Name: formattedName,
|
||||
@@ -1035,7 +1124,7 @@ func TestMetricServiceDeleteMetricDescriptor(t *testing.T) {
|
||||
|
||||
mockMetric.resps = append(mockMetric.resps[:0], expectedResponse)
|
||||
|
||||
var formattedName string = MetricMetricDescriptorPath("[PROJECT]", "[METRIC_DESCRIPTOR]")
|
||||
var formattedName string = fmt.Sprintf("projects/%s/metricDescriptors/%s", "[PROJECT]", "[METRIC_DESCRIPTOR]")
|
||||
var request = &monitoringpb.DeleteMetricDescriptorRequest{
|
||||
Name: formattedName,
|
||||
}
|
||||
@@ -1061,7 +1150,7 @@ func TestMetricServiceDeleteMetricDescriptorError(t *testing.T) {
|
||||
errCode := codes.PermissionDenied
|
||||
mockMetric.err = gstatus.Error(errCode, "test error")
|
||||
|
||||
var formattedName string = MetricMetricDescriptorPath("[PROJECT]", "[METRIC_DESCRIPTOR]")
|
||||
var formattedName string = fmt.Sprintf("projects/%s/metricDescriptors/%s", "[PROJECT]", "[METRIC_DESCRIPTOR]")
|
||||
var request = &monitoringpb.DeleteMetricDescriptorRequest{
|
||||
Name: formattedName,
|
||||
}
|
||||
@@ -1093,7 +1182,7 @@ func TestMetricServiceListTimeSeries(t *testing.T) {
|
||||
|
||||
mockMetric.resps = append(mockMetric.resps[:0], expectedResponse)
|
||||
|
||||
var formattedName string = MetricProjectPath("[PROJECT]")
|
||||
var formattedName string = fmt.Sprintf("projects/%s", "[PROJECT]")
|
||||
var filter string = "filter-1274492040"
|
||||
var interval *monitoringpb.TimeInterval = &monitoringpb.TimeInterval{}
|
||||
var view monitoringpb.ListTimeSeriesRequest_TimeSeriesView = monitoringpb.ListTimeSeriesRequest_FULL
|
||||
@@ -1138,7 +1227,7 @@ func TestMetricServiceListTimeSeriesError(t *testing.T) {
|
||||
errCode := codes.PermissionDenied
|
||||
mockMetric.err = gstatus.Error(errCode, "test error")
|
||||
|
||||
var formattedName string = MetricProjectPath("[PROJECT]")
|
||||
var formattedName string = fmt.Sprintf("projects/%s", "[PROJECT]")
|
||||
var filter string = "filter-1274492040"
|
||||
var interval *monitoringpb.TimeInterval = &monitoringpb.TimeInterval{}
|
||||
var view monitoringpb.ListTimeSeriesRequest_TimeSeriesView = monitoringpb.ListTimeSeriesRequest_FULL
|
||||
@@ -1171,7 +1260,7 @@ func TestMetricServiceCreateTimeSeries(t *testing.T) {
|
||||
|
||||
mockMetric.resps = append(mockMetric.resps[:0], expectedResponse)
|
||||
|
||||
var formattedName string = MetricProjectPath("[PROJECT]")
|
||||
var formattedName string = fmt.Sprintf("projects/%s", "[PROJECT]")
|
||||
var timeSeries []*monitoringpb.TimeSeries = nil
|
||||
var request = &monitoringpb.CreateTimeSeriesRequest{
|
||||
Name: formattedName,
|
||||
@@ -1199,7 +1288,7 @@ func TestMetricServiceCreateTimeSeriesError(t *testing.T) {
|
||||
errCode := codes.PermissionDenied
|
||||
mockMetric.err = gstatus.Error(errCode, "test error")
|
||||
|
||||
var formattedName string = MetricProjectPath("[PROJECT]")
|
||||
var formattedName string = fmt.Sprintf("projects/%s", "[PROJECT]")
|
||||
var timeSeries []*monitoringpb.TimeSeries = nil
|
||||
var request = &monitoringpb.CreateTimeSeriesRequest{
|
||||
Name: formattedName,
|
||||
@@ -1219,3 +1308,380 @@ func TestMetricServiceCreateTimeSeriesError(t *testing.T) {
|
||||
t.Errorf("got error code %q, want %q", c, errCode)
|
||||
}
|
||||
}
|
||||
func TestUptimeCheckServiceListUptimeCheckConfigs(t *testing.T) {
|
||||
var nextPageToken string = ""
|
||||
var uptimeCheckConfigsElement *monitoringpb.UptimeCheckConfig = &monitoringpb.UptimeCheckConfig{}
|
||||
var uptimeCheckConfigs = []*monitoringpb.UptimeCheckConfig{uptimeCheckConfigsElement}
|
||||
var expectedResponse = &monitoringpb.ListUptimeCheckConfigsResponse{
|
||||
NextPageToken: nextPageToken,
|
||||
UptimeCheckConfigs: uptimeCheckConfigs,
|
||||
}
|
||||
|
||||
mockUptimeCheck.err = nil
|
||||
mockUptimeCheck.reqs = nil
|
||||
|
||||
mockUptimeCheck.resps = append(mockUptimeCheck.resps[:0], expectedResponse)
|
||||
|
||||
var formattedParent string = fmt.Sprintf("projects/%s", "[PROJECT]")
|
||||
var request = &monitoringpb.ListUptimeCheckConfigsRequest{
|
||||
Parent: formattedParent,
|
||||
}
|
||||
|
||||
c, err := NewUptimeCheckClient(context.Background(), clientOpt)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
resp, err := c.ListUptimeCheckConfigs(context.Background(), request).Next()
|
||||
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
if want, got := request, mockUptimeCheck.reqs[0]; !proto.Equal(want, got) {
|
||||
t.Errorf("wrong request %q, want %q", got, want)
|
||||
}
|
||||
|
||||
want := (interface{})(expectedResponse.UptimeCheckConfigs[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 TestUptimeCheckServiceListUptimeCheckConfigsError(t *testing.T) {
|
||||
errCode := codes.PermissionDenied
|
||||
mockUptimeCheck.err = gstatus.Error(errCode, "test error")
|
||||
|
||||
var formattedParent string = fmt.Sprintf("projects/%s", "[PROJECT]")
|
||||
var request = &monitoringpb.ListUptimeCheckConfigsRequest{
|
||||
Parent: formattedParent,
|
||||
}
|
||||
|
||||
c, err := NewUptimeCheckClient(context.Background(), clientOpt)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
resp, err := c.ListUptimeCheckConfigs(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 TestUptimeCheckServiceGetUptimeCheckConfig(t *testing.T) {
|
||||
var name2 string = "name2-1052831874"
|
||||
var displayName string = "displayName1615086568"
|
||||
var expectedResponse = &monitoringpb.UptimeCheckConfig{
|
||||
Name: name2,
|
||||
DisplayName: displayName,
|
||||
}
|
||||
|
||||
mockUptimeCheck.err = nil
|
||||
mockUptimeCheck.reqs = nil
|
||||
|
||||
mockUptimeCheck.resps = append(mockUptimeCheck.resps[:0], expectedResponse)
|
||||
|
||||
var formattedName string = fmt.Sprintf("projects/%s/uptimeCheckConfigs/%s", "[PROJECT]", "[UPTIME_CHECK_CONFIG]")
|
||||
var request = &monitoringpb.GetUptimeCheckConfigRequest{
|
||||
Name: formattedName,
|
||||
}
|
||||
|
||||
c, err := NewUptimeCheckClient(context.Background(), clientOpt)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
resp, err := c.GetUptimeCheckConfig(context.Background(), request)
|
||||
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
if want, got := request, mockUptimeCheck.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 TestUptimeCheckServiceGetUptimeCheckConfigError(t *testing.T) {
|
||||
errCode := codes.PermissionDenied
|
||||
mockUptimeCheck.err = gstatus.Error(errCode, "test error")
|
||||
|
||||
var formattedName string = fmt.Sprintf("projects/%s/uptimeCheckConfigs/%s", "[PROJECT]", "[UPTIME_CHECK_CONFIG]")
|
||||
var request = &monitoringpb.GetUptimeCheckConfigRequest{
|
||||
Name: formattedName,
|
||||
}
|
||||
|
||||
c, err := NewUptimeCheckClient(context.Background(), clientOpt)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
resp, err := c.GetUptimeCheckConfig(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 TestUptimeCheckServiceCreateUptimeCheckConfig(t *testing.T) {
|
||||
var name string = "name3373707"
|
||||
var displayName string = "displayName1615086568"
|
||||
var expectedResponse = &monitoringpb.UptimeCheckConfig{
|
||||
Name: name,
|
||||
DisplayName: displayName,
|
||||
}
|
||||
|
||||
mockUptimeCheck.err = nil
|
||||
mockUptimeCheck.reqs = nil
|
||||
|
||||
mockUptimeCheck.resps = append(mockUptimeCheck.resps[:0], expectedResponse)
|
||||
|
||||
var formattedParent string = fmt.Sprintf("projects/%s", "[PROJECT]")
|
||||
var uptimeCheckConfig *monitoringpb.UptimeCheckConfig = &monitoringpb.UptimeCheckConfig{}
|
||||
var request = &monitoringpb.CreateUptimeCheckConfigRequest{
|
||||
Parent: formattedParent,
|
||||
UptimeCheckConfig: uptimeCheckConfig,
|
||||
}
|
||||
|
||||
c, err := NewUptimeCheckClient(context.Background(), clientOpt)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
resp, err := c.CreateUptimeCheckConfig(context.Background(), request)
|
||||
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
if want, got := request, mockUptimeCheck.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 TestUptimeCheckServiceCreateUptimeCheckConfigError(t *testing.T) {
|
||||
errCode := codes.PermissionDenied
|
||||
mockUptimeCheck.err = gstatus.Error(errCode, "test error")
|
||||
|
||||
var formattedParent string = fmt.Sprintf("projects/%s", "[PROJECT]")
|
||||
var uptimeCheckConfig *monitoringpb.UptimeCheckConfig = &monitoringpb.UptimeCheckConfig{}
|
||||
var request = &monitoringpb.CreateUptimeCheckConfigRequest{
|
||||
Parent: formattedParent,
|
||||
UptimeCheckConfig: uptimeCheckConfig,
|
||||
}
|
||||
|
||||
c, err := NewUptimeCheckClient(context.Background(), clientOpt)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
resp, err := c.CreateUptimeCheckConfig(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 TestUptimeCheckServiceUpdateUptimeCheckConfig(t *testing.T) {
|
||||
var name string = "name3373707"
|
||||
var displayName string = "displayName1615086568"
|
||||
var expectedResponse = &monitoringpb.UptimeCheckConfig{
|
||||
Name: name,
|
||||
DisplayName: displayName,
|
||||
}
|
||||
|
||||
mockUptimeCheck.err = nil
|
||||
mockUptimeCheck.reqs = nil
|
||||
|
||||
mockUptimeCheck.resps = append(mockUptimeCheck.resps[:0], expectedResponse)
|
||||
|
||||
var uptimeCheckConfig *monitoringpb.UptimeCheckConfig = &monitoringpb.UptimeCheckConfig{}
|
||||
var request = &monitoringpb.UpdateUptimeCheckConfigRequest{
|
||||
UptimeCheckConfig: uptimeCheckConfig,
|
||||
}
|
||||
|
||||
c, err := NewUptimeCheckClient(context.Background(), clientOpt)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
resp, err := c.UpdateUptimeCheckConfig(context.Background(), request)
|
||||
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
if want, got := request, mockUptimeCheck.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 TestUptimeCheckServiceUpdateUptimeCheckConfigError(t *testing.T) {
|
||||
errCode := codes.PermissionDenied
|
||||
mockUptimeCheck.err = gstatus.Error(errCode, "test error")
|
||||
|
||||
var uptimeCheckConfig *monitoringpb.UptimeCheckConfig = &monitoringpb.UptimeCheckConfig{}
|
||||
var request = &monitoringpb.UpdateUptimeCheckConfigRequest{
|
||||
UptimeCheckConfig: uptimeCheckConfig,
|
||||
}
|
||||
|
||||
c, err := NewUptimeCheckClient(context.Background(), clientOpt)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
resp, err := c.UpdateUptimeCheckConfig(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 TestUptimeCheckServiceDeleteUptimeCheckConfig(t *testing.T) {
|
||||
var expectedResponse *emptypb.Empty = &emptypb.Empty{}
|
||||
|
||||
mockUptimeCheck.err = nil
|
||||
mockUptimeCheck.reqs = nil
|
||||
|
||||
mockUptimeCheck.resps = append(mockUptimeCheck.resps[:0], expectedResponse)
|
||||
|
||||
var formattedName string = fmt.Sprintf("projects/%s/uptimeCheckConfigs/%s", "[PROJECT]", "[UPTIME_CHECK_CONFIG]")
|
||||
var request = &monitoringpb.DeleteUptimeCheckConfigRequest{
|
||||
Name: formattedName,
|
||||
}
|
||||
|
||||
c, err := NewUptimeCheckClient(context.Background(), clientOpt)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
err = c.DeleteUptimeCheckConfig(context.Background(), request)
|
||||
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
if want, got := request, mockUptimeCheck.reqs[0]; !proto.Equal(want, got) {
|
||||
t.Errorf("wrong request %q, want %q", got, want)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
func TestUptimeCheckServiceDeleteUptimeCheckConfigError(t *testing.T) {
|
||||
errCode := codes.PermissionDenied
|
||||
mockUptimeCheck.err = gstatus.Error(errCode, "test error")
|
||||
|
||||
var formattedName string = fmt.Sprintf("projects/%s/uptimeCheckConfigs/%s", "[PROJECT]", "[UPTIME_CHECK_CONFIG]")
|
||||
var request = &monitoringpb.DeleteUptimeCheckConfigRequest{
|
||||
Name: formattedName,
|
||||
}
|
||||
|
||||
c, err := NewUptimeCheckClient(context.Background(), clientOpt)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
err = c.DeleteUptimeCheckConfig(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)
|
||||
}
|
||||
}
|
||||
func TestUptimeCheckServiceListUptimeCheckIps(t *testing.T) {
|
||||
var nextPageToken string = ""
|
||||
var uptimeCheckIpsElement *monitoringpb.UptimeCheckIp = &monitoringpb.UptimeCheckIp{}
|
||||
var uptimeCheckIps = []*monitoringpb.UptimeCheckIp{uptimeCheckIpsElement}
|
||||
var expectedResponse = &monitoringpb.ListUptimeCheckIpsResponse{
|
||||
NextPageToken: nextPageToken,
|
||||
UptimeCheckIps: uptimeCheckIps,
|
||||
}
|
||||
|
||||
mockUptimeCheck.err = nil
|
||||
mockUptimeCheck.reqs = nil
|
||||
|
||||
mockUptimeCheck.resps = append(mockUptimeCheck.resps[:0], expectedResponse)
|
||||
|
||||
var request *monitoringpb.ListUptimeCheckIpsRequest = &monitoringpb.ListUptimeCheckIpsRequest{}
|
||||
|
||||
c, err := NewUptimeCheckClient(context.Background(), clientOpt)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
resp, err := c.ListUptimeCheckIps(context.Background(), request).Next()
|
||||
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
if want, got := request, mockUptimeCheck.reqs[0]; !proto.Equal(want, got) {
|
||||
t.Errorf("wrong request %q, want %q", got, want)
|
||||
}
|
||||
|
||||
want := (interface{})(expectedResponse.UptimeCheckIps[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 TestUptimeCheckServiceListUptimeCheckIpsError(t *testing.T) {
|
||||
errCode := codes.PermissionDenied
|
||||
mockUptimeCheck.err = gstatus.Error(errCode, "test error")
|
||||
|
||||
var request *monitoringpb.ListUptimeCheckIpsRequest = &monitoringpb.ListUptimeCheckIpsRequest{}
|
||||
|
||||
c, err := NewUptimeCheckClient(context.Background(), clientOpt)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
resp, err := c.ListUptimeCheckIps(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
|
||||
}
|
||||
|
||||
+107
@@ -0,0 +1,107 @@
|
||||
// Copyright 2018 Google LLC
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// https://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package monitoring
|
||||
|
||||
// GroupProjectPath returns the path for the project resource.
|
||||
//
|
||||
// Deprecated: Use
|
||||
// fmt.Sprintf("projects/%s", project)
|
||||
// instead.
|
||||
func GroupProjectPath(project string) string {
|
||||
return "" +
|
||||
"projects/" +
|
||||
project +
|
||||
""
|
||||
}
|
||||
|
||||
// GroupGroupPath returns the path for the group resource.
|
||||
//
|
||||
// Deprecated: Use
|
||||
// fmt.Sprintf("projects/%s/groups/%s", project, group)
|
||||
// instead.
|
||||
func GroupGroupPath(project, group string) string {
|
||||
return "" +
|
||||
"projects/" +
|
||||
project +
|
||||
"/groups/" +
|
||||
group +
|
||||
""
|
||||
}
|
||||
|
||||
// MetricProjectPath returns the path for the project resource.
|
||||
//
|
||||
// Deprecated: Use
|
||||
// fmt.Sprintf("projects/%s", project)
|
||||
// instead.
|
||||
func MetricProjectPath(project string) string {
|
||||
return "" +
|
||||
"projects/" +
|
||||
project +
|
||||
""
|
||||
}
|
||||
|
||||
// MetricMetricDescriptorPath returns the path for the metric descriptor resource.
|
||||
//
|
||||
// Deprecated: Use
|
||||
// fmt.Sprintf("projects/%s/metricDescriptors/%s", project, metricDescriptor)
|
||||
// instead.
|
||||
func MetricMetricDescriptorPath(project, metricDescriptor string) string {
|
||||
return "" +
|
||||
"projects/" +
|
||||
project +
|
||||
"/metricDescriptors/" +
|
||||
metricDescriptor +
|
||||
""
|
||||
}
|
||||
|
||||
// MetricMonitoredResourceDescriptorPath returns the path for the monitored resource descriptor resource.
|
||||
//
|
||||
// Deprecated: Use
|
||||
// fmt.Sprintf("projects/%s/monitoredResourceDescriptors/%s", project, monitoredResourceDescriptor)
|
||||
// instead.
|
||||
func MetricMonitoredResourceDescriptorPath(project, monitoredResourceDescriptor string) string {
|
||||
return "" +
|
||||
"projects/" +
|
||||
project +
|
||||
"/monitoredResourceDescriptors/" +
|
||||
monitoredResourceDescriptor +
|
||||
""
|
||||
}
|
||||
|
||||
// UptimeCheckProjectPath returns the path for the project resource.
|
||||
//
|
||||
// Deprecated: Use
|
||||
// fmt.Sprintf("projects/%s", project)
|
||||
// instead.
|
||||
func UptimeCheckProjectPath(project string) string {
|
||||
return "" +
|
||||
"projects/" +
|
||||
project +
|
||||
""
|
||||
}
|
||||
|
||||
// UptimeCheckUptimeCheckConfigPath returns the path for the uptime check config resource.
|
||||
//
|
||||
// Deprecated: Use
|
||||
// fmt.Sprintf("projects/%s/uptimeCheckConfigs/%s", project, uptimeCheckConfig)
|
||||
// instead.
|
||||
func UptimeCheckUptimeCheckConfigPath(project, uptimeCheckConfig string) string {
|
||||
return "" +
|
||||
"projects/" +
|
||||
project +
|
||||
"/uptimeCheckConfigs/" +
|
||||
uptimeCheckConfig +
|
||||
""
|
||||
}
|
||||
+355
@@ -0,0 +1,355 @@
|
||||
// Copyright 2018 Google LLC
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// https://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
// AUTO-GENERATED CODE. DO NOT EDIT.
|
||||
|
||||
package monitoring
|
||||
|
||||
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"
|
||||
monitoringpb "google.golang.org/genproto/googleapis/monitoring/v3"
|
||||
"google.golang.org/grpc"
|
||||
"google.golang.org/grpc/codes"
|
||||
"google.golang.org/grpc/metadata"
|
||||
)
|
||||
|
||||
// UptimeCheckCallOptions contains the retry settings for each method of UptimeCheckClient.
|
||||
type UptimeCheckCallOptions struct {
|
||||
ListUptimeCheckConfigs []gax.CallOption
|
||||
GetUptimeCheckConfig []gax.CallOption
|
||||
CreateUptimeCheckConfig []gax.CallOption
|
||||
UpdateUptimeCheckConfig []gax.CallOption
|
||||
DeleteUptimeCheckConfig []gax.CallOption
|
||||
ListUptimeCheckIps []gax.CallOption
|
||||
}
|
||||
|
||||
func defaultUptimeCheckClientOptions() []option.ClientOption {
|
||||
return []option.ClientOption{
|
||||
option.WithEndpoint("monitoring.googleapis.com:443"),
|
||||
option.WithScopes(DefaultAuthScopes()...),
|
||||
}
|
||||
}
|
||||
|
||||
func defaultUptimeCheckCallOptions() *UptimeCheckCallOptions {
|
||||
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 &UptimeCheckCallOptions{
|
||||
ListUptimeCheckConfigs: retry[[2]string{"default", "idempotent"}],
|
||||
GetUptimeCheckConfig: retry[[2]string{"default", "idempotent"}],
|
||||
CreateUptimeCheckConfig: retry[[2]string{"default", "non_idempotent"}],
|
||||
UpdateUptimeCheckConfig: retry[[2]string{"default", "non_idempotent"}],
|
||||
DeleteUptimeCheckConfig: retry[[2]string{"default", "idempotent"}],
|
||||
ListUptimeCheckIps: retry[[2]string{"default", "idempotent"}],
|
||||
}
|
||||
}
|
||||
|
||||
// UptimeCheckClient is a client for interacting with Stackdriver Monitoring API.
|
||||
type UptimeCheckClient struct {
|
||||
// The connection to the service.
|
||||
conn *grpc.ClientConn
|
||||
|
||||
// The gRPC API client.
|
||||
uptimeCheckClient monitoringpb.UptimeCheckServiceClient
|
||||
|
||||
// The call options for this service.
|
||||
CallOptions *UptimeCheckCallOptions
|
||||
|
||||
// The x-goog-* metadata to be sent with each request.
|
||||
xGoogMetadata metadata.MD
|
||||
}
|
||||
|
||||
// NewUptimeCheckClient creates a new uptime check service client.
|
||||
//
|
||||
// The UptimeCheckService API is used to manage (list, create, delete, edit)
|
||||
// uptime check configurations in the Stackdriver Monitoring product. An uptime
|
||||
// check is a piece of configuration that determines which resources and
|
||||
// services to monitor for availability. These configurations can also be
|
||||
// configured interactively by navigating to the [Cloud Console]
|
||||
// (http://console.cloud.google.com), selecting the appropriate project,
|
||||
// clicking on "Monitoring" on the left-hand side to navigate to Stackdriver,
|
||||
// and then clicking on "Uptime".
|
||||
func NewUptimeCheckClient(ctx context.Context, opts ...option.ClientOption) (*UptimeCheckClient, error) {
|
||||
conn, err := transport.DialGRPC(ctx, append(defaultUptimeCheckClientOptions(), opts...)...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
c := &UptimeCheckClient{
|
||||
conn: conn,
|
||||
CallOptions: defaultUptimeCheckCallOptions(),
|
||||
|
||||
uptimeCheckClient: monitoringpb.NewUptimeCheckServiceClient(conn),
|
||||
}
|
||||
c.setGoogleClientInfo()
|
||||
return c, nil
|
||||
}
|
||||
|
||||
// Connection returns the client's connection to the API service.
|
||||
func (c *UptimeCheckClient) 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 *UptimeCheckClient) 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 *UptimeCheckClient) setGoogleClientInfo(keyval ...string) {
|
||||
kv := append([]string{"gl-go", version.Go()}, keyval...)
|
||||
kv = append(kv, "gapic", version.Repo, "gax", gax.Version, "grpc", grpc.Version)
|
||||
c.xGoogMetadata = metadata.Pairs("x-goog-api-client", gax.XGoogHeader(kv...))
|
||||
}
|
||||
|
||||
// ListUptimeCheckConfigs lists the existing valid uptime check configurations for the project,
|
||||
// leaving out any invalid configurations.
|
||||
func (c *UptimeCheckClient) ListUptimeCheckConfigs(ctx context.Context, req *monitoringpb.ListUptimeCheckConfigsRequest, opts ...gax.CallOption) *UptimeCheckConfigIterator {
|
||||
ctx = insertMetadata(ctx, c.xGoogMetadata)
|
||||
opts = append(c.CallOptions.ListUptimeCheckConfigs[0:len(c.CallOptions.ListUptimeCheckConfigs):len(c.CallOptions.ListUptimeCheckConfigs)], opts...)
|
||||
it := &UptimeCheckConfigIterator{}
|
||||
it.InternalFetch = func(pageSize int, pageToken string) ([]*monitoringpb.UptimeCheckConfig, string, error) {
|
||||
var resp *monitoringpb.ListUptimeCheckConfigsResponse
|
||||
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.uptimeCheckClient.ListUptimeCheckConfigs(ctx, req, settings.GRPC...)
|
||||
return err
|
||||
}, opts...)
|
||||
if err != nil {
|
||||
return nil, "", err
|
||||
}
|
||||
return resp.UptimeCheckConfigs, 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
|
||||
}
|
||||
|
||||
// GetUptimeCheckConfig gets a single uptime check configuration.
|
||||
func (c *UptimeCheckClient) GetUptimeCheckConfig(ctx context.Context, req *monitoringpb.GetUptimeCheckConfigRequest, opts ...gax.CallOption) (*monitoringpb.UptimeCheckConfig, error) {
|
||||
ctx = insertMetadata(ctx, c.xGoogMetadata)
|
||||
opts = append(c.CallOptions.GetUptimeCheckConfig[0:len(c.CallOptions.GetUptimeCheckConfig):len(c.CallOptions.GetUptimeCheckConfig)], opts...)
|
||||
var resp *monitoringpb.UptimeCheckConfig
|
||||
err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
|
||||
var err error
|
||||
resp, err = c.uptimeCheckClient.GetUptimeCheckConfig(ctx, req, settings.GRPC...)
|
||||
return err
|
||||
}, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return resp, nil
|
||||
}
|
||||
|
||||
// CreateUptimeCheckConfig creates a new uptime check configuration.
|
||||
func (c *UptimeCheckClient) CreateUptimeCheckConfig(ctx context.Context, req *monitoringpb.CreateUptimeCheckConfigRequest, opts ...gax.CallOption) (*monitoringpb.UptimeCheckConfig, error) {
|
||||
ctx = insertMetadata(ctx, c.xGoogMetadata)
|
||||
opts = append(c.CallOptions.CreateUptimeCheckConfig[0:len(c.CallOptions.CreateUptimeCheckConfig):len(c.CallOptions.CreateUptimeCheckConfig)], opts...)
|
||||
var resp *monitoringpb.UptimeCheckConfig
|
||||
err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
|
||||
var err error
|
||||
resp, err = c.uptimeCheckClient.CreateUptimeCheckConfig(ctx, req, settings.GRPC...)
|
||||
return err
|
||||
}, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return resp, nil
|
||||
}
|
||||
|
||||
// UpdateUptimeCheckConfig updates an uptime check configuration. You can either replace the entire
|
||||
// configuration with a new one or replace only certain fields in the current
|
||||
// configuration by specifying the fields to be updated via "updateMask".
|
||||
// Returns the updated configuration.
|
||||
func (c *UptimeCheckClient) UpdateUptimeCheckConfig(ctx context.Context, req *monitoringpb.UpdateUptimeCheckConfigRequest, opts ...gax.CallOption) (*monitoringpb.UptimeCheckConfig, error) {
|
||||
ctx = insertMetadata(ctx, c.xGoogMetadata)
|
||||
opts = append(c.CallOptions.UpdateUptimeCheckConfig[0:len(c.CallOptions.UpdateUptimeCheckConfig):len(c.CallOptions.UpdateUptimeCheckConfig)], opts...)
|
||||
var resp *monitoringpb.UptimeCheckConfig
|
||||
err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
|
||||
var err error
|
||||
resp, err = c.uptimeCheckClient.UpdateUptimeCheckConfig(ctx, req, settings.GRPC...)
|
||||
return err
|
||||
}, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return resp, nil
|
||||
}
|
||||
|
||||
// DeleteUptimeCheckConfig deletes an uptime check configuration. Note that this method will fail
|
||||
// if the uptime check configuration is referenced by an alert policy or
|
||||
// other dependent configs that would be rendered invalid by the deletion.
|
||||
func (c *UptimeCheckClient) DeleteUptimeCheckConfig(ctx context.Context, req *monitoringpb.DeleteUptimeCheckConfigRequest, opts ...gax.CallOption) error {
|
||||
ctx = insertMetadata(ctx, c.xGoogMetadata)
|
||||
opts = append(c.CallOptions.DeleteUptimeCheckConfig[0:len(c.CallOptions.DeleteUptimeCheckConfig):len(c.CallOptions.DeleteUptimeCheckConfig)], opts...)
|
||||
err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error {
|
||||
var err error
|
||||
_, err = c.uptimeCheckClient.DeleteUptimeCheckConfig(ctx, req, settings.GRPC...)
|
||||
return err
|
||||
}, opts...)
|
||||
return err
|
||||
}
|
||||
|
||||
// ListUptimeCheckIps returns the list of IPs that checkers run from
|
||||
func (c *UptimeCheckClient) ListUptimeCheckIps(ctx context.Context, req *monitoringpb.ListUptimeCheckIpsRequest, opts ...gax.CallOption) *UptimeCheckIpIterator {
|
||||
ctx = insertMetadata(ctx, c.xGoogMetadata)
|
||||
opts = append(c.CallOptions.ListUptimeCheckIps[0:len(c.CallOptions.ListUptimeCheckIps):len(c.CallOptions.ListUptimeCheckIps)], opts...)
|
||||
it := &UptimeCheckIpIterator{}
|
||||
it.InternalFetch = func(pageSize int, pageToken string) ([]*monitoringpb.UptimeCheckIp, string, error) {
|
||||
var resp *monitoringpb.ListUptimeCheckIpsResponse
|
||||
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.uptimeCheckClient.ListUptimeCheckIps(ctx, req, settings.GRPC...)
|
||||
return err
|
||||
}, opts...)
|
||||
if err != nil {
|
||||
return nil, "", err
|
||||
}
|
||||
return resp.UptimeCheckIps, 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
|
||||
}
|
||||
|
||||
// UptimeCheckConfigIterator manages a stream of *monitoringpb.UptimeCheckConfig.
|
||||
type UptimeCheckConfigIterator struct {
|
||||
items []*monitoringpb.UptimeCheckConfig
|
||||
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 []*monitoringpb.UptimeCheckConfig, nextPageToken string, err error)
|
||||
}
|
||||
|
||||
// PageInfo supports pagination. See the google.golang.org/api/iterator package for details.
|
||||
func (it *UptimeCheckConfigIterator) 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 *UptimeCheckConfigIterator) Next() (*monitoringpb.UptimeCheckConfig, error) {
|
||||
var item *monitoringpb.UptimeCheckConfig
|
||||
if err := it.nextFunc(); err != nil {
|
||||
return item, err
|
||||
}
|
||||
item = it.items[0]
|
||||
it.items = it.items[1:]
|
||||
return item, nil
|
||||
}
|
||||
|
||||
func (it *UptimeCheckConfigIterator) bufLen() int {
|
||||
return len(it.items)
|
||||
}
|
||||
|
||||
func (it *UptimeCheckConfigIterator) takeBuf() interface{} {
|
||||
b := it.items
|
||||
it.items = nil
|
||||
return b
|
||||
}
|
||||
|
||||
// UptimeCheckIpIterator manages a stream of *monitoringpb.UptimeCheckIp.
|
||||
type UptimeCheckIpIterator struct {
|
||||
items []*monitoringpb.UptimeCheckIp
|
||||
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 []*monitoringpb.UptimeCheckIp, nextPageToken string, err error)
|
||||
}
|
||||
|
||||
// PageInfo supports pagination. See the google.golang.org/api/iterator package for details.
|
||||
func (it *UptimeCheckIpIterator) 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 *UptimeCheckIpIterator) Next() (*monitoringpb.UptimeCheckIp, error) {
|
||||
var item *monitoringpb.UptimeCheckIp
|
||||
if err := it.nextFunc(); err != nil {
|
||||
return item, err
|
||||
}
|
||||
item = it.items[0]
|
||||
it.items = it.items[1:]
|
||||
return item, nil
|
||||
}
|
||||
|
||||
func (it *UptimeCheckIpIterator) bufLen() int {
|
||||
return len(it.items)
|
||||
}
|
||||
|
||||
func (it *UptimeCheckIpIterator) takeBuf() interface{} {
|
||||
b := it.items
|
||||
it.items = nil
|
||||
return b
|
||||
}
|
||||
+152
@@ -0,0 +1,152 @@
|
||||
// Copyright 2018 Google LLC
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// https://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
// AUTO-GENERATED CODE. DO NOT EDIT.
|
||||
|
||||
package monitoring_test
|
||||
|
||||
import (
|
||||
"cloud.google.com/go/monitoring/apiv3"
|
||||
"golang.org/x/net/context"
|
||||
"google.golang.org/api/iterator"
|
||||
monitoringpb "google.golang.org/genproto/googleapis/monitoring/v3"
|
||||
)
|
||||
|
||||
func ExampleNewUptimeCheckClient() {
|
||||
ctx := context.Background()
|
||||
c, err := monitoring.NewUptimeCheckClient(ctx)
|
||||
if err != nil {
|
||||
// TODO: Handle error.
|
||||
}
|
||||
// TODO: Use client.
|
||||
_ = c
|
||||
}
|
||||
|
||||
func ExampleUptimeCheckClient_ListUptimeCheckConfigs() {
|
||||
ctx := context.Background()
|
||||
c, err := monitoring.NewUptimeCheckClient(ctx)
|
||||
if err != nil {
|
||||
// TODO: Handle error.
|
||||
}
|
||||
|
||||
req := &monitoringpb.ListUptimeCheckConfigsRequest{
|
||||
// TODO: Fill request struct fields.
|
||||
}
|
||||
it := c.ListUptimeCheckConfigs(ctx, req)
|
||||
for {
|
||||
resp, err := it.Next()
|
||||
if err == iterator.Done {
|
||||
break
|
||||
}
|
||||
if err != nil {
|
||||
// TODO: Handle error.
|
||||
}
|
||||
// TODO: Use resp.
|
||||
_ = resp
|
||||
}
|
||||
}
|
||||
|
||||
func ExampleUptimeCheckClient_GetUptimeCheckConfig() {
|
||||
ctx := context.Background()
|
||||
c, err := monitoring.NewUptimeCheckClient(ctx)
|
||||
if err != nil {
|
||||
// TODO: Handle error.
|
||||
}
|
||||
|
||||
req := &monitoringpb.GetUptimeCheckConfigRequest{
|
||||
// TODO: Fill request struct fields.
|
||||
}
|
||||
resp, err := c.GetUptimeCheckConfig(ctx, req)
|
||||
if err != nil {
|
||||
// TODO: Handle error.
|
||||
}
|
||||
// TODO: Use resp.
|
||||
_ = resp
|
||||
}
|
||||
|
||||
func ExampleUptimeCheckClient_CreateUptimeCheckConfig() {
|
||||
ctx := context.Background()
|
||||
c, err := monitoring.NewUptimeCheckClient(ctx)
|
||||
if err != nil {
|
||||
// TODO: Handle error.
|
||||
}
|
||||
|
||||
req := &monitoringpb.CreateUptimeCheckConfigRequest{
|
||||
// TODO: Fill request struct fields.
|
||||
}
|
||||
resp, err := c.CreateUptimeCheckConfig(ctx, req)
|
||||
if err != nil {
|
||||
// TODO: Handle error.
|
||||
}
|
||||
// TODO: Use resp.
|
||||
_ = resp
|
||||
}
|
||||
|
||||
func ExampleUptimeCheckClient_UpdateUptimeCheckConfig() {
|
||||
ctx := context.Background()
|
||||
c, err := monitoring.NewUptimeCheckClient(ctx)
|
||||
if err != nil {
|
||||
// TODO: Handle error.
|
||||
}
|
||||
|
||||
req := &monitoringpb.UpdateUptimeCheckConfigRequest{
|
||||
// TODO: Fill request struct fields.
|
||||
}
|
||||
resp, err := c.UpdateUptimeCheckConfig(ctx, req)
|
||||
if err != nil {
|
||||
// TODO: Handle error.
|
||||
}
|
||||
// TODO: Use resp.
|
||||
_ = resp
|
||||
}
|
||||
|
||||
func ExampleUptimeCheckClient_DeleteUptimeCheckConfig() {
|
||||
ctx := context.Background()
|
||||
c, err := monitoring.NewUptimeCheckClient(ctx)
|
||||
if err != nil {
|
||||
// TODO: Handle error.
|
||||
}
|
||||
|
||||
req := &monitoringpb.DeleteUptimeCheckConfigRequest{
|
||||
// TODO: Fill request struct fields.
|
||||
}
|
||||
err = c.DeleteUptimeCheckConfig(ctx, req)
|
||||
if err != nil {
|
||||
// TODO: Handle error.
|
||||
}
|
||||
}
|
||||
|
||||
func ExampleUptimeCheckClient_ListUptimeCheckIps() {
|
||||
ctx := context.Background()
|
||||
c, err := monitoring.NewUptimeCheckClient(ctx)
|
||||
if err != nil {
|
||||
// TODO: Handle error.
|
||||
}
|
||||
|
||||
req := &monitoringpb.ListUptimeCheckIpsRequest{
|
||||
// TODO: Fill request struct fields.
|
||||
}
|
||||
it := c.ListUptimeCheckIps(ctx, req)
|
||||
for {
|
||||
resp, err := it.Next()
|
||||
if err == iterator.Done {
|
||||
break
|
||||
}
|
||||
if err != nil {
|
||||
// TODO: Handle error.
|
||||
}
|
||||
// TODO: Use resp.
|
||||
_ = resp
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user