From f84938bb4042a5629fd66bda42de028fd833648a Mon Sep 17 00:00:00 2001 From: Cody Oss <6331106+codyoss@users.noreply.github.com> Date: Mon, 1 Feb 2021 13:11:45 -0700 Subject: [PATCH] feat(servicecontrol): start generating apiv1 (#3644) --- internal/.repo-metadata-full.json | 8 + internal/gapicgen/generator/config.go | 8 + servicecontrol/apiv1/doc.go | 113 ++++++++++ .../apiv1/quota_controller_client.go | 164 ++++++++++++++ .../quota_controller_client_example_test.go | 54 +++++ .../apiv1/service_controller_client.go | 202 ++++++++++++++++++ .../service_controller_client_example_test.go | 74 +++++++ 7 files changed, 623 insertions(+) create mode 100644 servicecontrol/apiv1/doc.go create mode 100644 servicecontrol/apiv1/quota_controller_client.go create mode 100644 servicecontrol/apiv1/quota_controller_client_example_test.go create mode 100644 servicecontrol/apiv1/service_controller_client.go create mode 100644 servicecontrol/apiv1/service_controller_client_example_test.go diff --git a/internal/.repo-metadata-full.json b/internal/.repo-metadata-full.json index 60f05d1add3..16ed7121ef9 100644 --- a/internal/.repo-metadata-full.json +++ b/internal/.repo-metadata-full.json @@ -823,6 +823,14 @@ "docs_url": "https://pkg.go.dev/cloud.google.com/go/securitycenter/settings/apiv1beta1", "release_level": "beta" }, + "cloud.google.com/go/servicecontrol/apiv1": { + "distribution_name": "cloud.google.com/go/servicecontrol/apiv1", + "description": "", + "language": "Go", + "client_library_type": "generated", + "docs_url": "https://pkg.go.dev/cloud.google.com/go/servicecontrol/apiv1", + "release_level": "beta" + }, "cloud.google.com/go/servicedirectory/apiv1": { "distribution_name": "cloud.google.com/go/servicedirectory/apiv1", "description": "Service Directory API", diff --git a/internal/gapicgen/generator/config.go b/internal/gapicgen/generator/config.go index 666973ed4e6..6b2f2115ab0 100644 --- a/internal/gapicgen/generator/config.go +++ b/internal/gapicgen/generator/config.go @@ -973,6 +973,14 @@ var microgenGapicConfigs = []*microgenConfig{ apiServiceConfigPath: "google/cloud/mediatranslation/v1beta1/mediatranslation_v1beta1.yaml", releaseLevel: "beta", }, + { + inputDirectoryPath: "google/api/servicecontrol/v1", + pkg: "servicecontrol", + importPath: "cloud.google.com/go/servicecontrol/apiv1", + apiServiceConfigPath: "google/api/servicecontrol/v1/servicecontrol_gapic.yaml", + // GA after 2021/03/01 + releaseLevel: "beta", + }, // Non-Cloud APIs { diff --git a/servicecontrol/apiv1/doc.go b/servicecontrol/apiv1/doc.go new file mode 100644 index 00000000000..078de5ad9e8 --- /dev/null +++ b/servicecontrol/apiv1/doc.go @@ -0,0 +1,113 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Code generated by protoc-gen-go_gapic. DO NOT EDIT. + +// +// Use of Context +// +// The ctx passed to NewClient is used for authentication requests and +// for creating the underlying connection, but is not used for subsequent calls. +// Individual methods on the client use the ctx given to them. +// +// To close the open connection, use the Close() method. +// +// For information about setting deadlines, reusing contexts, and more +// please visit pkg.go.dev/cloud.google.com/go. +package servicecontrol // import "cloud.google.com/go/servicecontrol/apiv1" + +import ( + "context" + "os" + "runtime" + "strconv" + "strings" + "unicode" + + "google.golang.org/api/option" + "google.golang.org/grpc/metadata" +) + +// For more information on implementing a client constructor hook, see +// https://github.com/googleapis/google-cloud-go/wiki/Customizing-constructors. +type clientHookParams struct{} +type clientHook func(context.Context, clientHookParams) ([]option.ClientOption, error) + +const versionClient = "20210201" + +func insertMetadata(ctx context.Context, mds ...metadata.MD) context.Context { + out, _ := metadata.FromOutgoingContext(ctx) + out = out.Copy() + for _, md := range mds { + for k, v := range md { + out[k] = append(out[k], v...) + } + } + return metadata.NewOutgoingContext(ctx, out) +} + +func checkDisableDeadlines() (bool, error) { + raw, ok := os.LookupEnv("GOOGLE_API_GO_EXPERIMENTAL_DISABLE_DEFAULT_DEADLINE") + if !ok { + return false, nil + } + + b, err := strconv.ParseBool(raw) + return b, err +} + +// DefaultAuthScopes reports the default set of authentication scopes to use with this package. +func DefaultAuthScopes() []string { + return []string{ + "https://www.googleapis.com/auth/cloud-platform", + "https://www.googleapis.com/auth/servicecontrol", + } +} + +// versionGo returns the Go runtime version. The returned string +// has no whitespace, suitable for reporting in header. +func versionGo() string { + const develPrefix = "devel +" + + s := runtime.Version() + if strings.HasPrefix(s, develPrefix) { + s = s[len(develPrefix):] + if p := strings.IndexFunc(s, unicode.IsSpace); p >= 0 { + s = s[:p] + } + return s + } + + notSemverRune := func(r rune) bool { + return !strings.ContainsRune("0123456789.", r) + } + + if strings.HasPrefix(s, "go1") { + s = s[2:] + var prerelease string + if p := strings.IndexFunc(s, notSemverRune); p >= 0 { + s, prerelease = s[:p], s[p:] + } + if strings.HasSuffix(s, ".") { + s += "0" + } else if strings.Count(s, ".") < 2 { + s += ".0" + } + if prerelease != "" { + s += "-" + prerelease + } + return s + } + return "UNKNOWN" +} diff --git a/servicecontrol/apiv1/quota_controller_client.go b/servicecontrol/apiv1/quota_controller_client.go new file mode 100644 index 00000000000..3b9b43792f1 --- /dev/null +++ b/servicecontrol/apiv1/quota_controller_client.go @@ -0,0 +1,164 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Code generated by protoc-gen-go_gapic. DO NOT EDIT. + +package servicecontrol + +import ( + "context" + "fmt" + "math" + "net/url" + + gax "github.com/googleapis/gax-go/v2" + "google.golang.org/api/option" + "google.golang.org/api/option/internaloption" + gtransport "google.golang.org/api/transport/grpc" + servicecontrolpb "google.golang.org/genproto/googleapis/api/servicecontrol/v1" + "google.golang.org/grpc" + "google.golang.org/grpc/metadata" +) + +var newQuotaControllerClientHook clientHook + +// QuotaControllerCallOptions contains the retry settings for each method of QuotaControllerClient. +type QuotaControllerCallOptions struct { + AllocateQuota []gax.CallOption +} + +func defaultQuotaControllerClientOptions() []option.ClientOption { + return []option.ClientOption{ + internaloption.WithDefaultEndpoint("servicecontrol.googleapis.com:443"), + internaloption.WithDefaultMTLSEndpoint("servicecontrol.mtls.googleapis.com:443"), + internaloption.WithDefaultAudience("https://servicecontrol.googleapis.com/"), + internaloption.WithDefaultScopes(DefaultAuthScopes()...), + option.WithGRPCDialOption(grpc.WithDisableServiceConfig()), + option.WithGRPCDialOption(grpc.WithDefaultCallOptions( + grpc.MaxCallRecvMsgSize(math.MaxInt32))), + } +} + +func defaultQuotaControllerCallOptions() *QuotaControllerCallOptions { + return &QuotaControllerCallOptions{ + AllocateQuota: []gax.CallOption{}, + } +} + +// QuotaControllerClient is a client for interacting with . +// +// Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls. +type QuotaControllerClient struct { + // Connection pool of gRPC connections to the service. + connPool gtransport.ConnPool + + // flag to opt out of default deadlines via GOOGLE_API_GO_EXPERIMENTAL_DISABLE_DEFAULT_DEADLINE + disableDeadlines bool + + // The gRPC API client. + quotaControllerClient servicecontrolpb.QuotaControllerClient + + // The call options for this service. + CallOptions *QuotaControllerCallOptions + + // The x-goog-* metadata to be sent with each request. + xGoogMetadata metadata.MD +} + +// NewQuotaControllerClient creates a new quota controller client. +// +// Google Quota Control API (at /service-control/overview) +// +// Allows clients to allocate and release quota against a managed +// service (at https://cloud.google.com/service-management/reference/rpc/google.api/servicemanagement.v1#google.api.servicemanagement.v1.ManagedService). +func NewQuotaControllerClient(ctx context.Context, opts ...option.ClientOption) (*QuotaControllerClient, error) { + clientOpts := defaultQuotaControllerClientOptions() + + if newQuotaControllerClientHook != nil { + hookOpts, err := newQuotaControllerClientHook(ctx, clientHookParams{}) + if err != nil { + return nil, err + } + clientOpts = append(clientOpts, hookOpts...) + } + + disableDeadlines, err := checkDisableDeadlines() + if err != nil { + return nil, err + } + + connPool, err := gtransport.DialPool(ctx, append(clientOpts, opts...)...) + if err != nil { + return nil, err + } + c := &QuotaControllerClient{ + connPool: connPool, + disableDeadlines: disableDeadlines, + CallOptions: defaultQuotaControllerCallOptions(), + + quotaControllerClient: servicecontrolpb.NewQuotaControllerClient(connPool), + } + c.setGoogleClientInfo() + + return c, nil +} + +// Connection returns a connection to the API service. +// +// Deprecated. +func (c *QuotaControllerClient) Connection() *grpc.ClientConn { + return c.connPool.Conn() +} + +// Close closes the connection to the API service. The user should invoke this when +// the client is no longer required. +func (c *QuotaControllerClient) Close() error { + return c.connPool.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 *QuotaControllerClient) setGoogleClientInfo(keyval ...string) { + kv := append([]string{"gl-go", versionGo()}, keyval...) + kv = append(kv, "gapic", versionClient, "gax", gax.Version, "grpc", grpc.Version) + c.xGoogMetadata = metadata.Pairs("x-goog-api-client", gax.XGoogHeader(kv...)) +} + +// AllocateQuota attempts to allocate quota for the specified consumer. It should be called +// before the operation is executed. +// +// This method requires the servicemanagement.services.quota +// permission on the specified service. For more information, see +// Cloud IAM (at https://cloud.google.com/iam). +// +// NOTE: The client must fail-open on server errors INTERNAL, +// UNKNOWN, DEADLINE_EXCEEDED, and UNAVAILABLE. To ensure system +// reliability, the server may inject these errors to prohibit any hard +// dependency on the quota functionality. +func (c *QuotaControllerClient) AllocateQuota(ctx context.Context, req *servicecontrolpb.AllocateQuotaRequest, opts ...gax.CallOption) (*servicecontrolpb.AllocateQuotaResponse, error) { + md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "service_name", url.QueryEscape(req.GetServiceName()))) + ctx = insertMetadata(ctx, c.xGoogMetadata, md) + opts = append(c.CallOptions.AllocateQuota[0:len(c.CallOptions.AllocateQuota):len(c.CallOptions.AllocateQuota)], opts...) + var resp *servicecontrolpb.AllocateQuotaResponse + err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { + var err error + resp, err = c.quotaControllerClient.AllocateQuota(ctx, req, settings.GRPC...) + return err + }, opts...) + if err != nil { + return nil, err + } + return resp, nil +} diff --git a/servicecontrol/apiv1/quota_controller_client_example_test.go b/servicecontrol/apiv1/quota_controller_client_example_test.go new file mode 100644 index 00000000000..bb015981be7 --- /dev/null +++ b/servicecontrol/apiv1/quota_controller_client_example_test.go @@ -0,0 +1,54 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Code generated by protoc-gen-go_gapic. DO NOT EDIT. + +package servicecontrol_test + +import ( + "context" + + servicecontrol "cloud.google.com/go/servicecontrol/apiv1" + servicecontrolpb "google.golang.org/genproto/googleapis/api/servicecontrol/v1" +) + +func ExampleNewQuotaControllerClient() { + ctx := context.Background() + c, err := servicecontrol.NewQuotaControllerClient(ctx) + if err != nil { + // TODO: Handle error. + } + // TODO: Use client. + _ = c +} + +func ExampleQuotaControllerClient_AllocateQuota() { + // import servicecontrolpb "google.golang.org/genproto/googleapis/api/servicecontrol/v1" + + ctx := context.Background() + c, err := servicecontrol.NewQuotaControllerClient(ctx) + if err != nil { + // TODO: Handle error. + } + + req := &servicecontrolpb.AllocateQuotaRequest{ + // TODO: Fill request struct fields. + } + resp, err := c.AllocateQuota(ctx, req) + if err != nil { + // TODO: Handle error. + } + // TODO: Use resp. + _ = resp +} diff --git a/servicecontrol/apiv1/service_controller_client.go b/servicecontrol/apiv1/service_controller_client.go new file mode 100644 index 00000000000..63fc65788c4 --- /dev/null +++ b/servicecontrol/apiv1/service_controller_client.go @@ -0,0 +1,202 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Code generated by protoc-gen-go_gapic. DO NOT EDIT. + +package servicecontrol + +import ( + "context" + "fmt" + "math" + "net/url" + + gax "github.com/googleapis/gax-go/v2" + "google.golang.org/api/option" + "google.golang.org/api/option/internaloption" + gtransport "google.golang.org/api/transport/grpc" + servicecontrolpb "google.golang.org/genproto/googleapis/api/servicecontrol/v1" + "google.golang.org/grpc" + "google.golang.org/grpc/metadata" +) + +var newServiceControllerClientHook clientHook + +// ServiceControllerCallOptions contains the retry settings for each method of ServiceControllerClient. +type ServiceControllerCallOptions struct { + Check []gax.CallOption + Report []gax.CallOption +} + +func defaultServiceControllerClientOptions() []option.ClientOption { + return []option.ClientOption{ + internaloption.WithDefaultEndpoint("servicecontrol.googleapis.com:443"), + internaloption.WithDefaultMTLSEndpoint("servicecontrol.mtls.googleapis.com:443"), + internaloption.WithDefaultAudience("https://servicecontrol.googleapis.com/"), + internaloption.WithDefaultScopes(DefaultAuthScopes()...), + option.WithGRPCDialOption(grpc.WithDisableServiceConfig()), + option.WithGRPCDialOption(grpc.WithDefaultCallOptions( + grpc.MaxCallRecvMsgSize(math.MaxInt32))), + } +} + +func defaultServiceControllerCallOptions() *ServiceControllerCallOptions { + return &ServiceControllerCallOptions{ + Check: []gax.CallOption{}, + Report: []gax.CallOption{}, + } +} + +// ServiceControllerClient is a client for interacting with . +// +// Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls. +type ServiceControllerClient struct { + // Connection pool of gRPC connections to the service. + connPool gtransport.ConnPool + + // flag to opt out of default deadlines via GOOGLE_API_GO_EXPERIMENTAL_DISABLE_DEFAULT_DEADLINE + disableDeadlines bool + + // The gRPC API client. + serviceControllerClient servicecontrolpb.ServiceControllerClient + + // The call options for this service. + CallOptions *ServiceControllerCallOptions + + // The x-goog-* metadata to be sent with each request. + xGoogMetadata metadata.MD +} + +// NewServiceControllerClient creates a new service controller client. +// +// Google Service Control API (at /service-control/overview) +// +// Lets clients check and report operations against a managed +// service (at https://cloud.google.com/service-management/reference/rpc/google.api/servicemanagement.v1#google.api.servicemanagement.v1.ManagedService). +func NewServiceControllerClient(ctx context.Context, opts ...option.ClientOption) (*ServiceControllerClient, error) { + clientOpts := defaultServiceControllerClientOptions() + + if newServiceControllerClientHook != nil { + hookOpts, err := newServiceControllerClientHook(ctx, clientHookParams{}) + if err != nil { + return nil, err + } + clientOpts = append(clientOpts, hookOpts...) + } + + disableDeadlines, err := checkDisableDeadlines() + if err != nil { + return nil, err + } + + connPool, err := gtransport.DialPool(ctx, append(clientOpts, opts...)...) + if err != nil { + return nil, err + } + c := &ServiceControllerClient{ + connPool: connPool, + disableDeadlines: disableDeadlines, + CallOptions: defaultServiceControllerCallOptions(), + + serviceControllerClient: servicecontrolpb.NewServiceControllerClient(connPool), + } + c.setGoogleClientInfo() + + return c, nil +} + +// Connection returns a connection to the API service. +// +// Deprecated. +func (c *ServiceControllerClient) Connection() *grpc.ClientConn { + return c.connPool.Conn() +} + +// Close closes the connection to the API service. The user should invoke this when +// the client is no longer required. +func (c *ServiceControllerClient) Close() error { + return c.connPool.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 *ServiceControllerClient) setGoogleClientInfo(keyval ...string) { + kv := append([]string{"gl-go", versionGo()}, keyval...) + kv = append(kv, "gapic", versionClient, "gax", gax.Version, "grpc", grpc.Version) + c.xGoogMetadata = metadata.Pairs("x-goog-api-client", gax.XGoogHeader(kv...)) +} + +// Check checks whether an operation on a service should be allowed to proceed +// based on the configuration of the service and related policies. It must be +// called before the operation is executed. +// +// If feasible, the client should cache the check results and reuse them for +// 60 seconds. In case of any server errors, the client should rely on the +// cached results for much longer time to avoid outage. +// WARNING: There is general 60s delay for the configuration and policy +// propagation, therefore callers MUST NOT depend on the Check method having +// the latest policy information. +// +// NOTE: the CheckRequest has the size limit of 64KB. +// +// This method requires the servicemanagement.services.check permission +// on the specified service. For more information, see +// Cloud IAM (at https://cloud.google.com/iam). +func (c *ServiceControllerClient) Check(ctx context.Context, req *servicecontrolpb.CheckRequest, opts ...gax.CallOption) (*servicecontrolpb.CheckResponse, error) { + md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "service_name", url.QueryEscape(req.GetServiceName()))) + ctx = insertMetadata(ctx, c.xGoogMetadata, md) + opts = append(c.CallOptions.Check[0:len(c.CallOptions.Check):len(c.CallOptions.Check)], opts...) + var resp *servicecontrolpb.CheckResponse + err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { + var err error + resp, err = c.serviceControllerClient.Check(ctx, req, settings.GRPC...) + return err + }, opts...) + if err != nil { + return nil, err + } + return resp, nil +} + +// Report reports operation results to Google Service Control, such as logs and +// metrics. It should be called after an operation is completed. +// +// If feasible, the client should aggregate reporting data for up to 5 +// seconds to reduce API traffic. Limiting aggregation to 5 seconds is to +// reduce data loss during client crashes. Clients should carefully choose +// the aggregation time window to avoid data loss risk more than 0.01% +// for business and compliance reasons. +// +// NOTE: the ReportRequest has the size limit (wire-format byte size) of +// 1MB. +// +// This method requires the servicemanagement.services.report permission +// on the specified service. For more information, see +// Google Cloud IAM (at https://cloud.google.com/iam). +func (c *ServiceControllerClient) Report(ctx context.Context, req *servicecontrolpb.ReportRequest, opts ...gax.CallOption) (*servicecontrolpb.ReportResponse, error) { + md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "service_name", url.QueryEscape(req.GetServiceName()))) + ctx = insertMetadata(ctx, c.xGoogMetadata, md) + opts = append(c.CallOptions.Report[0:len(c.CallOptions.Report):len(c.CallOptions.Report)], opts...) + var resp *servicecontrolpb.ReportResponse + err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { + var err error + resp, err = c.serviceControllerClient.Report(ctx, req, settings.GRPC...) + return err + }, opts...) + if err != nil { + return nil, err + } + return resp, nil +} diff --git a/servicecontrol/apiv1/service_controller_client_example_test.go b/servicecontrol/apiv1/service_controller_client_example_test.go new file mode 100644 index 00000000000..8894f62d58a --- /dev/null +++ b/servicecontrol/apiv1/service_controller_client_example_test.go @@ -0,0 +1,74 @@ +// Copyright 2021 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Code generated by protoc-gen-go_gapic. DO NOT EDIT. + +package servicecontrol_test + +import ( + "context" + + servicecontrol "cloud.google.com/go/servicecontrol/apiv1" + servicecontrolpb "google.golang.org/genproto/googleapis/api/servicecontrol/v1" +) + +func ExampleNewServiceControllerClient() { + ctx := context.Background() + c, err := servicecontrol.NewServiceControllerClient(ctx) + if err != nil { + // TODO: Handle error. + } + // TODO: Use client. + _ = c +} + +func ExampleServiceControllerClient_Check() { + // import servicecontrolpb "google.golang.org/genproto/googleapis/api/servicecontrol/v1" + + ctx := context.Background() + c, err := servicecontrol.NewServiceControllerClient(ctx) + if err != nil { + // TODO: Handle error. + } + + req := &servicecontrolpb.CheckRequest{ + // TODO: Fill request struct fields. + } + resp, err := c.Check(ctx, req) + if err != nil { + // TODO: Handle error. + } + // TODO: Use resp. + _ = resp +} + +func ExampleServiceControllerClient_Report() { + // import servicecontrolpb "google.golang.org/genproto/googleapis/api/servicecontrol/v1" + + ctx := context.Background() + c, err := servicecontrol.NewServiceControllerClient(ctx) + if err != nil { + // TODO: Handle error. + } + + req := &servicecontrolpb.ReportRequest{ + // TODO: Fill request struct fields. + } + resp, err := c.Report(ctx, req) + if err != nil { + // TODO: Handle error. + } + // TODO: Use resp. + _ = resp +}