Service Control API v1 - Package cloud.google.com/go/servicecontrol/apiv1 (v0.83.0)

Package servicecontrol is an auto-generated package for the Service Control API.

Provides control plane functionality to managed services, such as logging, monitoring, and status checks.

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 https://pkg.go.dev/cloud.google.com/go.

Functions

func DefaultAuthScopes

func DefaultAuthScopes() []string

DefaultAuthScopes reports the default set of authentication scopes to use with this package.

QuotaControllerCallOptions

type QuotaControllerCallOptions struct {
	AllocateQuota []gax.CallOption
}

QuotaControllerCallOptions contains the retry settings for each method of QuotaControllerClient.

QuotaControllerClient

type QuotaControllerClient struct {

	// The call options for this service.
	CallOptions *QuotaControllerCallOptions
	// contains filtered or unexported fields
}

QuotaControllerClient is a client for interacting with Service Control API. Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls.

Google Quota Control API (at https://cloud.google.com/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

func NewQuotaControllerClient(ctx context.Context, opts ...option.ClientOption) (*QuotaControllerClient, error)

NewQuotaControllerClient creates a new quota controller client based on gRPC. The returned client must be Closed when it is done being used to clean up its underlying connections.

Google Quota Control API (at https://cloud.google.com/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).

Example

package main

import (
	"context"

	servicecontrol "cloud.google.com/go/servicecontrol/apiv1"
)

func main() {
	ctx := context.Background()
	c, err := servicecontrol.NewQuotaControllerClient(ctx)
	if err != nil {
		// TODO: Handle error.
	}
	defer c.Close()

	// TODO: Use client.
	_ = c
}

func (*QuotaControllerClient) AllocateQuota

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.

Example

package main

import (
	"context"

	servicecontrol "cloud.google.com/go/servicecontrol/apiv1"
	servicecontrolpb "google.golang.org/genproto/googleapis/api/servicecontrol/v1"
)

func main() {
	ctx := context.Background()
	c, err := servicecontrol.NewQuotaControllerClient(ctx)
	if err != nil {
		// TODO: Handle error.
	}
	defer c.Close()

	req := &servicecontrolpb.AllocateQuotaRequest{
		// TODO: Fill request struct fields.
	}
	resp, err := c.AllocateQuota(ctx, req)
	if err != nil {
		// TODO: Handle error.
	}
	// TODO: Use resp.
	_ = resp
}

func (*QuotaControllerClient) Close

func (c *QuotaControllerClient) Close() error

Close closes the connection to the API service. The user should invoke this when the client is no longer required.

func (*QuotaControllerClient) Connection

func (c *QuotaControllerClient) Connection() *grpc.ClientConn

Connection returns a connection to the API service.

Deprecated.

ServiceControllerCallOptions

type ServiceControllerCallOptions struct {
	Check  []gax.CallOption
	Report []gax.CallOption
}

ServiceControllerCallOptions contains the retry settings for each method of ServiceControllerClient.

ServiceControllerClient

type ServiceControllerClient struct {

	// The call options for this service.
	CallOptions *ServiceControllerCallOptions
	// contains filtered or unexported fields
}

ServiceControllerClient is a client for interacting with Service Control API. Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls.

Google Service Control API (at https://cloud.google.com/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

func NewServiceControllerClient(ctx context.Context, opts ...option.ClientOption) (*ServiceControllerClient, error)

NewServiceControllerClient creates a new service controller client based on gRPC. The returned client must be Closed when it is done being used to clean up its underlying connections.

Google Service Control API (at https://cloud.google.com/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).

Example

package main

import (
	"context"

	servicecontrol "cloud.google.com/go/servicecontrol/apiv1"
)

func main() {
	ctx := context.Background()
	c, err := servicecontrol.NewServiceControllerClient(ctx)
	if err != nil {
		// TODO: Handle error.
	}
	defer c.Close()

	// TODO: Use client.
	_ = c
}

func (*ServiceControllerClient) Check

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).

Example

package main

import (
	"context"

	servicecontrol "cloud.google.com/go/servicecontrol/apiv1"
	servicecontrolpb "google.golang.org/genproto/googleapis/api/servicecontrol/v1"
)

func main() {
	ctx := context.Background()
	c, err := servicecontrol.NewServiceControllerClient(ctx)
	if err != nil {
		// TODO: Handle error.
	}
	defer c.Close()

	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 (*ServiceControllerClient) Close

func (c *ServiceControllerClient) Close() error

Close closes the connection to the API service. The user should invoke this when the client is no longer required.

func (*ServiceControllerClient) Connection

func (c *ServiceControllerClient) Connection() *grpc.ClientConn

Connection returns a connection to the API service.

Deprecated.

func (*ServiceControllerClient) Report

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).

Example

package main

import (
	"context"

	servicecontrol "cloud.google.com/go/servicecontrol/apiv1"
	servicecontrolpb "google.golang.org/genproto/googleapis/api/servicecontrol/v1"
)

func main() {
	ctx := context.Background()
	c, err := servicecontrol.NewServiceControllerClient(ctx)
	if err != nil {
		// TODO: Handle error.
	}
	defer c.Close()

	req := &servicecontrolpb.ReportRequest{
		// TODO: Fill request struct fields.
	}
	resp, err := c.Report(ctx, req)
	if err != nil {
		// TODO: Handle error.
	}
	// TODO: Use resp.
	_ = resp
}