diff --git a/gaming/apiv1/doc.go b/gaming/apiv1/doc.go new file mode 100644 index 00000000000..b722ba673aa --- /dev/null +++ b/gaming/apiv1/doc.go @@ -0,0 +1,102 @@ +// Copyright 2020 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. + +// +// NOTE: This package is in beta. It is not stable, and may be subject to changes. +// +// 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 godoc.org/cloud.google.com/go. +package gaming // import "cloud.google.com/go/gaming/apiv1" + +import ( + "context" + "runtime" + "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 = "20200804" + +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) +} + +// 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", + } +} + +// 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/gaming/apiv1/game_server_clusters_client.go b/gaming/apiv1/game_server_clusters_client.go new file mode 100644 index 00000000000..40604bf01ad --- /dev/null +++ b/gaming/apiv1/game_server_clusters_client.go @@ -0,0 +1,619 @@ +// Copyright 2020 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 gaming + +import ( + "context" + "fmt" + "math" + "net/url" + "time" + + "cloud.google.com/go/longrunning" + lroauto "cloud.google.com/go/longrunning/autogen" + "github.com/golang/protobuf/proto" + gax "github.com/googleapis/gax-go/v2" + "google.golang.org/api/iterator" + "google.golang.org/api/option" + gtransport "google.golang.org/api/transport/grpc" + gamingpb "google.golang.org/genproto/googleapis/cloud/gaming/v1" + longrunningpb "google.golang.org/genproto/googleapis/longrunning" + "google.golang.org/grpc" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/metadata" +) + +var newGameServerClustersClientHook clientHook + +// GameServerClustersCallOptions contains the retry settings for each method of GameServerClustersClient. +type GameServerClustersCallOptions struct { + ListGameServerClusters []gax.CallOption + GetGameServerCluster []gax.CallOption + CreateGameServerCluster []gax.CallOption + PreviewCreateGameServerCluster []gax.CallOption + DeleteGameServerCluster []gax.CallOption + PreviewDeleteGameServerCluster []gax.CallOption + UpdateGameServerCluster []gax.CallOption + PreviewUpdateGameServerCluster []gax.CallOption +} + +func defaultGameServerClustersClientOptions() []option.ClientOption { + return []option.ClientOption{ + option.WithEndpoint("gameservices.googleapis.com:443"), + option.WithGRPCDialOption(grpc.WithDisableServiceConfig()), + option.WithScopes(DefaultAuthScopes()...), + option.WithGRPCDialOption(grpc.WithDefaultCallOptions( + grpc.MaxCallRecvMsgSize(math.MaxInt32))), + } +} + +func defaultGameServerClustersCallOptions() *GameServerClustersCallOptions { + return &GameServerClustersCallOptions{ + ListGameServerClusters: []gax.CallOption{ + gax.WithRetry(func() gax.Retryer { + return gax.OnCodes([]codes.Code{ + codes.Unavailable, + }, gax.Backoff{ + Initial: 1000 * time.Millisecond, + Max: 10000 * time.Millisecond, + Multiplier: 1.30, + }) + }), + }, + GetGameServerCluster: []gax.CallOption{ + gax.WithRetry(func() gax.Retryer { + return gax.OnCodes([]codes.Code{ + codes.Unavailable, + }, gax.Backoff{ + Initial: 1000 * time.Millisecond, + Max: 10000 * time.Millisecond, + Multiplier: 1.30, + }) + }), + }, + CreateGameServerCluster: []gax.CallOption{}, + PreviewCreateGameServerCluster: []gax.CallOption{ + gax.WithRetry(func() gax.Retryer { + return gax.OnCodes([]codes.Code{ + codes.Unavailable, + }, gax.Backoff{ + Initial: 1000 * time.Millisecond, + Max: 10000 * time.Millisecond, + Multiplier: 1.30, + }) + }), + }, + DeleteGameServerCluster: []gax.CallOption{}, + PreviewDeleteGameServerCluster: []gax.CallOption{ + gax.WithRetry(func() gax.Retryer { + return gax.OnCodes([]codes.Code{ + codes.Unavailable, + }, gax.Backoff{ + Initial: 1000 * time.Millisecond, + Max: 10000 * time.Millisecond, + Multiplier: 1.30, + }) + }), + }, + UpdateGameServerCluster: []gax.CallOption{}, + PreviewUpdateGameServerCluster: []gax.CallOption{ + gax.WithRetry(func() gax.Retryer { + return gax.OnCodes([]codes.Code{ + codes.Unavailable, + }, gax.Backoff{ + Initial: 1000 * time.Millisecond, + Max: 10000 * time.Millisecond, + Multiplier: 1.30, + }) + }), + }, + } +} + +// GameServerClustersClient is a client for interacting with . +// +// Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls. +type GameServerClustersClient struct { + // Connection pool of gRPC connections to the service. + connPool gtransport.ConnPool + + // The gRPC API client. + gameServerClustersClient gamingpb.GameServerClustersServiceClient + + // LROClient is used internally to handle longrunning operations. + // It is exposed so that its CallOptions can be modified if required. + // Users should not Close this client. + LROClient *lroauto.OperationsClient + + // The call options for this service. + CallOptions *GameServerClustersCallOptions + + // The x-goog-* metadata to be sent with each request. + xGoogMetadata metadata.MD +} + +// NewGameServerClustersClient creates a new game server clusters service client. +// +// The game server cluster maps to Kubernetes clusters running Agones and is +// used to manage fleets within clusters. +func NewGameServerClustersClient(ctx context.Context, opts ...option.ClientOption) (*GameServerClustersClient, error) { + clientOpts := defaultGameServerClustersClientOptions() + + if newGameServerClustersClientHook != nil { + hookOpts, err := newGameServerClustersClientHook(ctx, clientHookParams{}) + if err != nil { + return nil, err + } + clientOpts = append(clientOpts, hookOpts...) + } + + connPool, err := gtransport.DialPool(ctx, append(clientOpts, opts...)...) + if err != nil { + return nil, err + } + c := &GameServerClustersClient{ + connPool: connPool, + CallOptions: defaultGameServerClustersCallOptions(), + + gameServerClustersClient: gamingpb.NewGameServerClustersServiceClient(connPool), + } + c.setGoogleClientInfo() + + c.LROClient, err = lroauto.NewOperationsClient(ctx, gtransport.WithConnPool(connPool)) + if err != nil { + // This error "should not happen", since we are just reusing old connection pool + // and never actually need to dial. + // If this does happen, we could leak connp. However, we cannot close conn: + // If the user invoked the constructor with option.WithGRPCConn, + // we would close a connection that's still in use. + // TODO: investigate error conditions. + return nil, err + } + return c, nil +} + +// Connection returns a connection to the API service. +// +// Deprecated. +func (c *GameServerClustersClient) 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 *GameServerClustersClient) 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 *GameServerClustersClient) 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...)) +} + +// ListGameServerClusters lists game server clusters in a given project and location. +func (c *GameServerClustersClient) ListGameServerClusters(ctx context.Context, req *gamingpb.ListGameServerClustersRequest, opts ...gax.CallOption) *GameServerClusterIterator { + md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))) + ctx = insertMetadata(ctx, c.xGoogMetadata, md) + opts = append(c.CallOptions.ListGameServerClusters[0:len(c.CallOptions.ListGameServerClusters):len(c.CallOptions.ListGameServerClusters)], opts...) + it := &GameServerClusterIterator{} + req = proto.Clone(req).(*gamingpb.ListGameServerClustersRequest) + it.InternalFetch = func(pageSize int, pageToken string) ([]*gamingpb.GameServerCluster, string, error) { + var resp *gamingpb.ListGameServerClustersResponse + 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.gameServerClustersClient.ListGameServerClusters(ctx, req, settings.GRPC...) + return err + }, opts...) + if err != nil { + return nil, "", err + } + + it.Response = resp + return resp.GameServerClusters, 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) + it.pageInfo.MaxSize = int(req.PageSize) + it.pageInfo.Token = req.PageToken + return it +} + +// GetGameServerCluster gets details of a single game server cluster. +func (c *GameServerClustersClient) GetGameServerCluster(ctx context.Context, req *gamingpb.GetGameServerClusterRequest, opts ...gax.CallOption) (*gamingpb.GameServerCluster, error) { + md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))) + ctx = insertMetadata(ctx, c.xGoogMetadata, md) + opts = append(c.CallOptions.GetGameServerCluster[0:len(c.CallOptions.GetGameServerCluster):len(c.CallOptions.GetGameServerCluster)], opts...) + var resp *gamingpb.GameServerCluster + err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { + var err error + resp, err = c.gameServerClustersClient.GetGameServerCluster(ctx, req, settings.GRPC...) + return err + }, opts...) + if err != nil { + return nil, err + } + return resp, nil +} + +// CreateGameServerCluster creates a new game server cluster in a given project and location. +func (c *GameServerClustersClient) CreateGameServerCluster(ctx context.Context, req *gamingpb.CreateGameServerClusterRequest, opts ...gax.CallOption) (*CreateGameServerClusterOperation, error) { + md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))) + ctx = insertMetadata(ctx, c.xGoogMetadata, md) + opts = append(c.CallOptions.CreateGameServerCluster[0:len(c.CallOptions.CreateGameServerCluster):len(c.CallOptions.CreateGameServerCluster)], opts...) + var resp *longrunningpb.Operation + err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { + var err error + resp, err = c.gameServerClustersClient.CreateGameServerCluster(ctx, req, settings.GRPC...) + return err + }, opts...) + if err != nil { + return nil, err + } + return &CreateGameServerClusterOperation{ + lro: longrunning.InternalNewOperation(c.LROClient, resp), + }, nil +} + +// PreviewCreateGameServerCluster previews creation of a new game server cluster in a given project and +// location. +func (c *GameServerClustersClient) PreviewCreateGameServerCluster(ctx context.Context, req *gamingpb.PreviewCreateGameServerClusterRequest, opts ...gax.CallOption) (*gamingpb.PreviewCreateGameServerClusterResponse, error) { + md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))) + ctx = insertMetadata(ctx, c.xGoogMetadata, md) + opts = append(c.CallOptions.PreviewCreateGameServerCluster[0:len(c.CallOptions.PreviewCreateGameServerCluster):len(c.CallOptions.PreviewCreateGameServerCluster)], opts...) + var resp *gamingpb.PreviewCreateGameServerClusterResponse + err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { + var err error + resp, err = c.gameServerClustersClient.PreviewCreateGameServerCluster(ctx, req, settings.GRPC...) + return err + }, opts...) + if err != nil { + return nil, err + } + return resp, nil +} + +// DeleteGameServerCluster deletes a single game server cluster. +func (c *GameServerClustersClient) DeleteGameServerCluster(ctx context.Context, req *gamingpb.DeleteGameServerClusterRequest, opts ...gax.CallOption) (*DeleteGameServerClusterOperation, error) { + md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))) + ctx = insertMetadata(ctx, c.xGoogMetadata, md) + opts = append(c.CallOptions.DeleteGameServerCluster[0:len(c.CallOptions.DeleteGameServerCluster):len(c.CallOptions.DeleteGameServerCluster)], opts...) + var resp *longrunningpb.Operation + err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { + var err error + resp, err = c.gameServerClustersClient.DeleteGameServerCluster(ctx, req, settings.GRPC...) + return err + }, opts...) + if err != nil { + return nil, err + } + return &DeleteGameServerClusterOperation{ + lro: longrunning.InternalNewOperation(c.LROClient, resp), + }, nil +} + +// PreviewDeleteGameServerCluster previews deletion of a single game server cluster. +func (c *GameServerClustersClient) PreviewDeleteGameServerCluster(ctx context.Context, req *gamingpb.PreviewDeleteGameServerClusterRequest, opts ...gax.CallOption) (*gamingpb.PreviewDeleteGameServerClusterResponse, error) { + md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))) + ctx = insertMetadata(ctx, c.xGoogMetadata, md) + opts = append(c.CallOptions.PreviewDeleteGameServerCluster[0:len(c.CallOptions.PreviewDeleteGameServerCluster):len(c.CallOptions.PreviewDeleteGameServerCluster)], opts...) + var resp *gamingpb.PreviewDeleteGameServerClusterResponse + err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { + var err error + resp, err = c.gameServerClustersClient.PreviewDeleteGameServerCluster(ctx, req, settings.GRPC...) + return err + }, opts...) + if err != nil { + return nil, err + } + return resp, nil +} + +// UpdateGameServerCluster patches a single game server cluster. +func (c *GameServerClustersClient) UpdateGameServerCluster(ctx context.Context, req *gamingpb.UpdateGameServerClusterRequest, opts ...gax.CallOption) (*UpdateGameServerClusterOperation, error) { + md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "game_server_cluster.name", url.QueryEscape(req.GetGameServerCluster().GetName()))) + ctx = insertMetadata(ctx, c.xGoogMetadata, md) + opts = append(c.CallOptions.UpdateGameServerCluster[0:len(c.CallOptions.UpdateGameServerCluster):len(c.CallOptions.UpdateGameServerCluster)], opts...) + var resp *longrunningpb.Operation + err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { + var err error + resp, err = c.gameServerClustersClient.UpdateGameServerCluster(ctx, req, settings.GRPC...) + return err + }, opts...) + if err != nil { + return nil, err + } + return &UpdateGameServerClusterOperation{ + lro: longrunning.InternalNewOperation(c.LROClient, resp), + }, nil +} + +// PreviewUpdateGameServerCluster previews updating a GameServerCluster. +func (c *GameServerClustersClient) PreviewUpdateGameServerCluster(ctx context.Context, req *gamingpb.PreviewUpdateGameServerClusterRequest, opts ...gax.CallOption) (*gamingpb.PreviewUpdateGameServerClusterResponse, error) { + md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "game_server_cluster.name", url.QueryEscape(req.GetGameServerCluster().GetName()))) + ctx = insertMetadata(ctx, c.xGoogMetadata, md) + opts = append(c.CallOptions.PreviewUpdateGameServerCluster[0:len(c.CallOptions.PreviewUpdateGameServerCluster):len(c.CallOptions.PreviewUpdateGameServerCluster)], opts...) + var resp *gamingpb.PreviewUpdateGameServerClusterResponse + err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { + var err error + resp, err = c.gameServerClustersClient.PreviewUpdateGameServerCluster(ctx, req, settings.GRPC...) + return err + }, opts...) + if err != nil { + return nil, err + } + return resp, nil +} + +// CreateGameServerClusterOperation manages a long-running operation from CreateGameServerCluster. +type CreateGameServerClusterOperation struct { + lro *longrunning.Operation +} + +// CreateGameServerClusterOperation returns a new CreateGameServerClusterOperation from a given name. +// The name must be that of a previously created CreateGameServerClusterOperation, possibly from a different process. +func (c *GameServerClustersClient) CreateGameServerClusterOperation(name string) *CreateGameServerClusterOperation { + return &CreateGameServerClusterOperation{ + lro: longrunning.InternalNewOperation(c.LROClient, &longrunningpb.Operation{Name: name}), + } +} + +// Wait blocks until the long-running operation is completed, returning the response and any errors encountered. +// +// See documentation of Poll for error-handling information. +func (op *CreateGameServerClusterOperation) Wait(ctx context.Context, opts ...gax.CallOption) (*gamingpb.GameServerCluster, error) { + var resp gamingpb.GameServerCluster + if err := op.lro.WaitWithInterval(ctx, &resp, time.Minute, opts...); err != nil { + return nil, err + } + return &resp, nil +} + +// Poll fetches the latest state of the long-running operation. +// +// Poll also fetches the latest metadata, which can be retrieved by Metadata. +// +// If Poll fails, the error is returned and op is unmodified. If Poll succeeds and +// the operation has completed with failure, the error is returned and op.Done will return true. +// If Poll succeeds and the operation has completed successfully, +// op.Done will return true, and the response of the operation is returned. +// If Poll succeeds and the operation has not completed, the returned response and error are both nil. +func (op *CreateGameServerClusterOperation) Poll(ctx context.Context, opts ...gax.CallOption) (*gamingpb.GameServerCluster, error) { + var resp gamingpb.GameServerCluster + if err := op.lro.Poll(ctx, &resp, opts...); err != nil { + return nil, err + } + if !op.Done() { + return nil, nil + } + return &resp, nil +} + +// Metadata returns metadata associated with the long-running operation. +// Metadata itself does not contact the server, but Poll does. +// To get the latest metadata, call this method after a successful call to Poll. +// If the metadata is not available, the returned metadata and error are both nil. +func (op *CreateGameServerClusterOperation) Metadata() (*gamingpb.OperationMetadata, error) { + var meta gamingpb.OperationMetadata + if err := op.lro.Metadata(&meta); err == longrunning.ErrNoMetadata { + return nil, nil + } else if err != nil { + return nil, err + } + return &meta, nil +} + +// Done reports whether the long-running operation has completed. +func (op *CreateGameServerClusterOperation) Done() bool { + return op.lro.Done() +} + +// Name returns the name of the long-running operation. +// The name is assigned by the server and is unique within the service from which the operation is created. +func (op *CreateGameServerClusterOperation) Name() string { + return op.lro.Name() +} + +// DeleteGameServerClusterOperation manages a long-running operation from DeleteGameServerCluster. +type DeleteGameServerClusterOperation struct { + lro *longrunning.Operation +} + +// DeleteGameServerClusterOperation returns a new DeleteGameServerClusterOperation from a given name. +// The name must be that of a previously created DeleteGameServerClusterOperation, possibly from a different process. +func (c *GameServerClustersClient) DeleteGameServerClusterOperation(name string) *DeleteGameServerClusterOperation { + return &DeleteGameServerClusterOperation{ + lro: longrunning.InternalNewOperation(c.LROClient, &longrunningpb.Operation{Name: name}), + } +} + +// Wait blocks until the long-running operation is completed, returning the response and any errors encountered. +// +// See documentation of Poll for error-handling information. +func (op *DeleteGameServerClusterOperation) Wait(ctx context.Context, opts ...gax.CallOption) error { + return op.lro.WaitWithInterval(ctx, nil, time.Minute, opts...) +} + +// Poll fetches the latest state of the long-running operation. +// +// Poll also fetches the latest metadata, which can be retrieved by Metadata. +// +// If Poll fails, the error is returned and op is unmodified. If Poll succeeds and +// the operation has completed with failure, the error is returned and op.Done will return true. +// If Poll succeeds and the operation has completed successfully, +// op.Done will return true, and the response of the operation is returned. +// If Poll succeeds and the operation has not completed, the returned response and error are both nil. +func (op *DeleteGameServerClusterOperation) Poll(ctx context.Context, opts ...gax.CallOption) error { + return op.lro.Poll(ctx, nil, opts...) +} + +// Metadata returns metadata associated with the long-running operation. +// Metadata itself does not contact the server, but Poll does. +// To get the latest metadata, call this method after a successful call to Poll. +// If the metadata is not available, the returned metadata and error are both nil. +func (op *DeleteGameServerClusterOperation) Metadata() (*gamingpb.OperationMetadata, error) { + var meta gamingpb.OperationMetadata + if err := op.lro.Metadata(&meta); err == longrunning.ErrNoMetadata { + return nil, nil + } else if err != nil { + return nil, err + } + return &meta, nil +} + +// Done reports whether the long-running operation has completed. +func (op *DeleteGameServerClusterOperation) Done() bool { + return op.lro.Done() +} + +// Name returns the name of the long-running operation. +// The name is assigned by the server and is unique within the service from which the operation is created. +func (op *DeleteGameServerClusterOperation) Name() string { + return op.lro.Name() +} + +// UpdateGameServerClusterOperation manages a long-running operation from UpdateGameServerCluster. +type UpdateGameServerClusterOperation struct { + lro *longrunning.Operation +} + +// UpdateGameServerClusterOperation returns a new UpdateGameServerClusterOperation from a given name. +// The name must be that of a previously created UpdateGameServerClusterOperation, possibly from a different process. +func (c *GameServerClustersClient) UpdateGameServerClusterOperation(name string) *UpdateGameServerClusterOperation { + return &UpdateGameServerClusterOperation{ + lro: longrunning.InternalNewOperation(c.LROClient, &longrunningpb.Operation{Name: name}), + } +} + +// Wait blocks until the long-running operation is completed, returning the response and any errors encountered. +// +// See documentation of Poll for error-handling information. +func (op *UpdateGameServerClusterOperation) Wait(ctx context.Context, opts ...gax.CallOption) (*gamingpb.GameServerCluster, error) { + var resp gamingpb.GameServerCluster + if err := op.lro.WaitWithInterval(ctx, &resp, time.Minute, opts...); err != nil { + return nil, err + } + return &resp, nil +} + +// Poll fetches the latest state of the long-running operation. +// +// Poll also fetches the latest metadata, which can be retrieved by Metadata. +// +// If Poll fails, the error is returned and op is unmodified. If Poll succeeds and +// the operation has completed with failure, the error is returned and op.Done will return true. +// If Poll succeeds and the operation has completed successfully, +// op.Done will return true, and the response of the operation is returned. +// If Poll succeeds and the operation has not completed, the returned response and error are both nil. +func (op *UpdateGameServerClusterOperation) Poll(ctx context.Context, opts ...gax.CallOption) (*gamingpb.GameServerCluster, error) { + var resp gamingpb.GameServerCluster + if err := op.lro.Poll(ctx, &resp, opts...); err != nil { + return nil, err + } + if !op.Done() { + return nil, nil + } + return &resp, nil +} + +// Metadata returns metadata associated with the long-running operation. +// Metadata itself does not contact the server, but Poll does. +// To get the latest metadata, call this method after a successful call to Poll. +// If the metadata is not available, the returned metadata and error are both nil. +func (op *UpdateGameServerClusterOperation) Metadata() (*gamingpb.OperationMetadata, error) { + var meta gamingpb.OperationMetadata + if err := op.lro.Metadata(&meta); err == longrunning.ErrNoMetadata { + return nil, nil + } else if err != nil { + return nil, err + } + return &meta, nil +} + +// Done reports whether the long-running operation has completed. +func (op *UpdateGameServerClusterOperation) Done() bool { + return op.lro.Done() +} + +// Name returns the name of the long-running operation. +// The name is assigned by the server and is unique within the service from which the operation is created. +func (op *UpdateGameServerClusterOperation) Name() string { + return op.lro.Name() +} + +// GameServerClusterIterator manages a stream of *gamingpb.GameServerCluster. +type GameServerClusterIterator struct { + items []*gamingpb.GameServerCluster + pageInfo *iterator.PageInfo + nextFunc func() error + + // Response is the raw response for the current page. + // It must be cast to the RPC response type. + // Calling Next() or InternalFetch() updates this value. + Response interface{} + + // 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 []*gamingpb.GameServerCluster, nextPageToken string, err error) +} + +// PageInfo supports pagination. See the google.golang.org/api/iterator package for details. +func (it *GameServerClusterIterator) 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 *GameServerClusterIterator) Next() (*gamingpb.GameServerCluster, error) { + var item *gamingpb.GameServerCluster + if err := it.nextFunc(); err != nil { + return item, err + } + item = it.items[0] + it.items = it.items[1:] + return item, nil +} + +func (it *GameServerClusterIterator) bufLen() int { + return len(it.items) +} + +func (it *GameServerClusterIterator) takeBuf() interface{} { + b := it.items + it.items = nil + return b +} diff --git a/gaming/apiv1/game_server_clusters_client_example_test.go b/gaming/apiv1/game_server_clusters_client_example_test.go new file mode 100644 index 00000000000..6fa63588a1a --- /dev/null +++ b/gaming/apiv1/game_server_clusters_client_example_test.go @@ -0,0 +1,215 @@ +// Copyright 2020 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 gaming_test + +import ( + "context" + + gaming "cloud.google.com/go/gaming/apiv1" + "google.golang.org/api/iterator" + gamingpb "google.golang.org/genproto/googleapis/cloud/gaming/v1" +) + +func ExampleNewGameServerClustersClient() { + ctx := context.Background() + c, err := gaming.NewGameServerClustersClient(ctx) + if err != nil { + // TODO: Handle error. + } + // TODO: Use client. + _ = c +} + +func ExampleGameServerClustersClient_ListGameServerClusters() { + // import gamingpb "google.golang.org/genproto/googleapis/cloud/gaming/v1" + // import "google.golang.org/api/iterator" + + ctx := context.Background() + c, err := gaming.NewGameServerClustersClient(ctx) + if err != nil { + // TODO: Handle error. + } + + req := &gamingpb.ListGameServerClustersRequest{ + // TODO: Fill request struct fields. + } + it := c.ListGameServerClusters(ctx, req) + for { + resp, err := it.Next() + if err == iterator.Done { + break + } + if err != nil { + // TODO: Handle error. + } + // TODO: Use resp. + _ = resp + } +} + +func ExampleGameServerClustersClient_GetGameServerCluster() { + // import gamingpb "google.golang.org/genproto/googleapis/cloud/gaming/v1" + + ctx := context.Background() + c, err := gaming.NewGameServerClustersClient(ctx) + if err != nil { + // TODO: Handle error. + } + + req := &gamingpb.GetGameServerClusterRequest{ + // TODO: Fill request struct fields. + } + resp, err := c.GetGameServerCluster(ctx, req) + if err != nil { + // TODO: Handle error. + } + // TODO: Use resp. + _ = resp +} + +func ExampleGameServerClustersClient_CreateGameServerCluster() { + // import gamingpb "google.golang.org/genproto/googleapis/cloud/gaming/v1" + + ctx := context.Background() + c, err := gaming.NewGameServerClustersClient(ctx) + if err != nil { + // TODO: Handle error. + } + + req := &gamingpb.CreateGameServerClusterRequest{ + // TODO: Fill request struct fields. + } + op, err := c.CreateGameServerCluster(ctx, req) + if err != nil { + // TODO: Handle error. + } + + resp, err := op.Wait(ctx) + if err != nil { + // TODO: Handle error. + } + // TODO: Use resp. + _ = resp +} + +func ExampleGameServerClustersClient_PreviewCreateGameServerCluster() { + // import gamingpb "google.golang.org/genproto/googleapis/cloud/gaming/v1" + + ctx := context.Background() + c, err := gaming.NewGameServerClustersClient(ctx) + if err != nil { + // TODO: Handle error. + } + + req := &gamingpb.PreviewCreateGameServerClusterRequest{ + // TODO: Fill request struct fields. + } + resp, err := c.PreviewCreateGameServerCluster(ctx, req) + if err != nil { + // TODO: Handle error. + } + // TODO: Use resp. + _ = resp +} + +func ExampleGameServerClustersClient_DeleteGameServerCluster() { + // import gamingpb "google.golang.org/genproto/googleapis/cloud/gaming/v1" + + ctx := context.Background() + c, err := gaming.NewGameServerClustersClient(ctx) + if err != nil { + // TODO: Handle error. + } + + req := &gamingpb.DeleteGameServerClusterRequest{ + // TODO: Fill request struct fields. + } + op, err := c.DeleteGameServerCluster(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) + if err != nil { + // TODO: Handle error. + } +} + +func ExampleGameServerClustersClient_PreviewDeleteGameServerCluster() { + // import gamingpb "google.golang.org/genproto/googleapis/cloud/gaming/v1" + + ctx := context.Background() + c, err := gaming.NewGameServerClustersClient(ctx) + if err != nil { + // TODO: Handle error. + } + + req := &gamingpb.PreviewDeleteGameServerClusterRequest{ + // TODO: Fill request struct fields. + } + resp, err := c.PreviewDeleteGameServerCluster(ctx, req) + if err != nil { + // TODO: Handle error. + } + // TODO: Use resp. + _ = resp +} + +func ExampleGameServerClustersClient_UpdateGameServerCluster() { + // import gamingpb "google.golang.org/genproto/googleapis/cloud/gaming/v1" + + ctx := context.Background() + c, err := gaming.NewGameServerClustersClient(ctx) + if err != nil { + // TODO: Handle error. + } + + req := &gamingpb.UpdateGameServerClusterRequest{ + // TODO: Fill request struct fields. + } + op, err := c.UpdateGameServerCluster(ctx, req) + if err != nil { + // TODO: Handle error. + } + + resp, err := op.Wait(ctx) + if err != nil { + // TODO: Handle error. + } + // TODO: Use resp. + _ = resp +} + +func ExampleGameServerClustersClient_PreviewUpdateGameServerCluster() { + // import gamingpb "google.golang.org/genproto/googleapis/cloud/gaming/v1" + + ctx := context.Background() + c, err := gaming.NewGameServerClustersClient(ctx) + if err != nil { + // TODO: Handle error. + } + + req := &gamingpb.PreviewUpdateGameServerClusterRequest{ + // TODO: Fill request struct fields. + } + resp, err := c.PreviewUpdateGameServerCluster(ctx, req) + if err != nil { + // TODO: Handle error. + } + // TODO: Use resp. + _ = resp +} diff --git a/gaming/apiv1/game_server_configs_client.go b/gaming/apiv1/game_server_configs_client.go new file mode 100644 index 00000000000..d27f238e01b --- /dev/null +++ b/gaming/apiv1/game_server_configs_client.go @@ -0,0 +1,444 @@ +// Copyright 2020 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 gaming + +import ( + "context" + "fmt" + "math" + "net/url" + "time" + + "cloud.google.com/go/longrunning" + lroauto "cloud.google.com/go/longrunning/autogen" + "github.com/golang/protobuf/proto" + gax "github.com/googleapis/gax-go/v2" + "google.golang.org/api/iterator" + "google.golang.org/api/option" + gtransport "google.golang.org/api/transport/grpc" + gamingpb "google.golang.org/genproto/googleapis/cloud/gaming/v1" + longrunningpb "google.golang.org/genproto/googleapis/longrunning" + "google.golang.org/grpc" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/metadata" +) + +var newGameServerConfigsClientHook clientHook + +// GameServerConfigsCallOptions contains the retry settings for each method of GameServerConfigsClient. +type GameServerConfigsCallOptions struct { + ListGameServerConfigs []gax.CallOption + GetGameServerConfig []gax.CallOption + CreateGameServerConfig []gax.CallOption + DeleteGameServerConfig []gax.CallOption +} + +func defaultGameServerConfigsClientOptions() []option.ClientOption { + return []option.ClientOption{ + option.WithEndpoint("gameservices.googleapis.com:443"), + option.WithGRPCDialOption(grpc.WithDisableServiceConfig()), + option.WithScopes(DefaultAuthScopes()...), + option.WithGRPCDialOption(grpc.WithDefaultCallOptions( + grpc.MaxCallRecvMsgSize(math.MaxInt32))), + } +} + +func defaultGameServerConfigsCallOptions() *GameServerConfigsCallOptions { + return &GameServerConfigsCallOptions{ + ListGameServerConfigs: []gax.CallOption{ + gax.WithRetry(func() gax.Retryer { + return gax.OnCodes([]codes.Code{ + codes.Unavailable, + }, gax.Backoff{ + Initial: 1000 * time.Millisecond, + Max: 10000 * time.Millisecond, + Multiplier: 1.30, + }) + }), + }, + GetGameServerConfig: []gax.CallOption{ + gax.WithRetry(func() gax.Retryer { + return gax.OnCodes([]codes.Code{ + codes.Unavailable, + }, gax.Backoff{ + Initial: 1000 * time.Millisecond, + Max: 10000 * time.Millisecond, + Multiplier: 1.30, + }) + }), + }, + CreateGameServerConfig: []gax.CallOption{}, + DeleteGameServerConfig: []gax.CallOption{}, + } +} + +// GameServerConfigsClient is a client for interacting with . +// +// Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls. +type GameServerConfigsClient struct { + // Connection pool of gRPC connections to the service. + connPool gtransport.ConnPool + + // The gRPC API client. + gameServerConfigsClient gamingpb.GameServerConfigsServiceClient + + // LROClient is used internally to handle longrunning operations. + // It is exposed so that its CallOptions can be modified if required. + // Users should not Close this client. + LROClient *lroauto.OperationsClient + + // The call options for this service. + CallOptions *GameServerConfigsCallOptions + + // The x-goog-* metadata to be sent with each request. + xGoogMetadata metadata.MD +} + +// NewGameServerConfigsClient creates a new game server configs service client. +// +// The game server config configures the game servers in an Agones fleet. +func NewGameServerConfigsClient(ctx context.Context, opts ...option.ClientOption) (*GameServerConfigsClient, error) { + clientOpts := defaultGameServerConfigsClientOptions() + + if newGameServerConfigsClientHook != nil { + hookOpts, err := newGameServerConfigsClientHook(ctx, clientHookParams{}) + if err != nil { + return nil, err + } + clientOpts = append(clientOpts, hookOpts...) + } + + connPool, err := gtransport.DialPool(ctx, append(clientOpts, opts...)...) + if err != nil { + return nil, err + } + c := &GameServerConfigsClient{ + connPool: connPool, + CallOptions: defaultGameServerConfigsCallOptions(), + + gameServerConfigsClient: gamingpb.NewGameServerConfigsServiceClient(connPool), + } + c.setGoogleClientInfo() + + c.LROClient, err = lroauto.NewOperationsClient(ctx, gtransport.WithConnPool(connPool)) + if err != nil { + // This error "should not happen", since we are just reusing old connection pool + // and never actually need to dial. + // If this does happen, we could leak connp. However, we cannot close conn: + // If the user invoked the constructor with option.WithGRPCConn, + // we would close a connection that's still in use. + // TODO: investigate error conditions. + return nil, err + } + return c, nil +} + +// Connection returns a connection to the API service. +// +// Deprecated. +func (c *GameServerConfigsClient) 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 *GameServerConfigsClient) 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 *GameServerConfigsClient) 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...)) +} + +// ListGameServerConfigs lists game server configs in a given project, location, and game server +// deployment. +func (c *GameServerConfigsClient) ListGameServerConfigs(ctx context.Context, req *gamingpb.ListGameServerConfigsRequest, opts ...gax.CallOption) *GameServerConfigIterator { + md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))) + ctx = insertMetadata(ctx, c.xGoogMetadata, md) + opts = append(c.CallOptions.ListGameServerConfigs[0:len(c.CallOptions.ListGameServerConfigs):len(c.CallOptions.ListGameServerConfigs)], opts...) + it := &GameServerConfigIterator{} + req = proto.Clone(req).(*gamingpb.ListGameServerConfigsRequest) + it.InternalFetch = func(pageSize int, pageToken string) ([]*gamingpb.GameServerConfig, string, error) { + var resp *gamingpb.ListGameServerConfigsResponse + 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.gameServerConfigsClient.ListGameServerConfigs(ctx, req, settings.GRPC...) + return err + }, opts...) + if err != nil { + return nil, "", err + } + + it.Response = resp + return resp.GameServerConfigs, 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) + it.pageInfo.MaxSize = int(req.PageSize) + it.pageInfo.Token = req.PageToken + return it +} + +// GetGameServerConfig gets details of a single game server config. +func (c *GameServerConfigsClient) GetGameServerConfig(ctx context.Context, req *gamingpb.GetGameServerConfigRequest, opts ...gax.CallOption) (*gamingpb.GameServerConfig, error) { + md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))) + ctx = insertMetadata(ctx, c.xGoogMetadata, md) + opts = append(c.CallOptions.GetGameServerConfig[0:len(c.CallOptions.GetGameServerConfig):len(c.CallOptions.GetGameServerConfig)], opts...) + var resp *gamingpb.GameServerConfig + err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { + var err error + resp, err = c.gameServerConfigsClient.GetGameServerConfig(ctx, req, settings.GRPC...) + return err + }, opts...) + if err != nil { + return nil, err + } + return resp, nil +} + +// CreateGameServerConfig creates a new game server config in a given project, location, and game +// server deployment. Game server configs are immutable, and are not applied +// until referenced in the game server deployment rollout resource. +func (c *GameServerConfigsClient) CreateGameServerConfig(ctx context.Context, req *gamingpb.CreateGameServerConfigRequest, opts ...gax.CallOption) (*CreateGameServerConfigOperation, error) { + md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))) + ctx = insertMetadata(ctx, c.xGoogMetadata, md) + opts = append(c.CallOptions.CreateGameServerConfig[0:len(c.CallOptions.CreateGameServerConfig):len(c.CallOptions.CreateGameServerConfig)], opts...) + var resp *longrunningpb.Operation + err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { + var err error + resp, err = c.gameServerConfigsClient.CreateGameServerConfig(ctx, req, settings.GRPC...) + return err + }, opts...) + if err != nil { + return nil, err + } + return &CreateGameServerConfigOperation{ + lro: longrunning.InternalNewOperation(c.LROClient, resp), + }, nil +} + +// DeleteGameServerConfig deletes a single game server config. The deletion will fail if the game +// server config is referenced in a game server deployment rollout. +func (c *GameServerConfigsClient) DeleteGameServerConfig(ctx context.Context, req *gamingpb.DeleteGameServerConfigRequest, opts ...gax.CallOption) (*DeleteGameServerConfigOperation, error) { + md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))) + ctx = insertMetadata(ctx, c.xGoogMetadata, md) + opts = append(c.CallOptions.DeleteGameServerConfig[0:len(c.CallOptions.DeleteGameServerConfig):len(c.CallOptions.DeleteGameServerConfig)], opts...) + var resp *longrunningpb.Operation + err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { + var err error + resp, err = c.gameServerConfigsClient.DeleteGameServerConfig(ctx, req, settings.GRPC...) + return err + }, opts...) + if err != nil { + return nil, err + } + return &DeleteGameServerConfigOperation{ + lro: longrunning.InternalNewOperation(c.LROClient, resp), + }, nil +} + +// CreateGameServerConfigOperation manages a long-running operation from CreateGameServerConfig. +type CreateGameServerConfigOperation struct { + lro *longrunning.Operation +} + +// CreateGameServerConfigOperation returns a new CreateGameServerConfigOperation from a given name. +// The name must be that of a previously created CreateGameServerConfigOperation, possibly from a different process. +func (c *GameServerConfigsClient) CreateGameServerConfigOperation(name string) *CreateGameServerConfigOperation { + return &CreateGameServerConfigOperation{ + lro: longrunning.InternalNewOperation(c.LROClient, &longrunningpb.Operation{Name: name}), + } +} + +// Wait blocks until the long-running operation is completed, returning the response and any errors encountered. +// +// See documentation of Poll for error-handling information. +func (op *CreateGameServerConfigOperation) Wait(ctx context.Context, opts ...gax.CallOption) (*gamingpb.GameServerConfig, error) { + var resp gamingpb.GameServerConfig + if err := op.lro.WaitWithInterval(ctx, &resp, time.Minute, opts...); err != nil { + return nil, err + } + return &resp, nil +} + +// Poll fetches the latest state of the long-running operation. +// +// Poll also fetches the latest metadata, which can be retrieved by Metadata. +// +// If Poll fails, the error is returned and op is unmodified. If Poll succeeds and +// the operation has completed with failure, the error is returned and op.Done will return true. +// If Poll succeeds and the operation has completed successfully, +// op.Done will return true, and the response of the operation is returned. +// If Poll succeeds and the operation has not completed, the returned response and error are both nil. +func (op *CreateGameServerConfigOperation) Poll(ctx context.Context, opts ...gax.CallOption) (*gamingpb.GameServerConfig, error) { + var resp gamingpb.GameServerConfig + if err := op.lro.Poll(ctx, &resp, opts...); err != nil { + return nil, err + } + if !op.Done() { + return nil, nil + } + return &resp, nil +} + +// Metadata returns metadata associated with the long-running operation. +// Metadata itself does not contact the server, but Poll does. +// To get the latest metadata, call this method after a successful call to Poll. +// If the metadata is not available, the returned metadata and error are both nil. +func (op *CreateGameServerConfigOperation) Metadata() (*gamingpb.OperationMetadata, error) { + var meta gamingpb.OperationMetadata + if err := op.lro.Metadata(&meta); err == longrunning.ErrNoMetadata { + return nil, nil + } else if err != nil { + return nil, err + } + return &meta, nil +} + +// Done reports whether the long-running operation has completed. +func (op *CreateGameServerConfigOperation) Done() bool { + return op.lro.Done() +} + +// Name returns the name of the long-running operation. +// The name is assigned by the server and is unique within the service from which the operation is created. +func (op *CreateGameServerConfigOperation) Name() string { + return op.lro.Name() +} + +// DeleteGameServerConfigOperation manages a long-running operation from DeleteGameServerConfig. +type DeleteGameServerConfigOperation struct { + lro *longrunning.Operation +} + +// DeleteGameServerConfigOperation returns a new DeleteGameServerConfigOperation from a given name. +// The name must be that of a previously created DeleteGameServerConfigOperation, possibly from a different process. +func (c *GameServerConfigsClient) DeleteGameServerConfigOperation(name string) *DeleteGameServerConfigOperation { + return &DeleteGameServerConfigOperation{ + lro: longrunning.InternalNewOperation(c.LROClient, &longrunningpb.Operation{Name: name}), + } +} + +// Wait blocks until the long-running operation is completed, returning the response and any errors encountered. +// +// See documentation of Poll for error-handling information. +func (op *DeleteGameServerConfigOperation) Wait(ctx context.Context, opts ...gax.CallOption) error { + return op.lro.WaitWithInterval(ctx, nil, time.Minute, opts...) +} + +// Poll fetches the latest state of the long-running operation. +// +// Poll also fetches the latest metadata, which can be retrieved by Metadata. +// +// If Poll fails, the error is returned and op is unmodified. If Poll succeeds and +// the operation has completed with failure, the error is returned and op.Done will return true. +// If Poll succeeds and the operation has completed successfully, +// op.Done will return true, and the response of the operation is returned. +// If Poll succeeds and the operation has not completed, the returned response and error are both nil. +func (op *DeleteGameServerConfigOperation) Poll(ctx context.Context, opts ...gax.CallOption) error { + return op.lro.Poll(ctx, nil, opts...) +} + +// Metadata returns metadata associated with the long-running operation. +// Metadata itself does not contact the server, but Poll does. +// To get the latest metadata, call this method after a successful call to Poll. +// If the metadata is not available, the returned metadata and error are both nil. +func (op *DeleteGameServerConfigOperation) Metadata() (*gamingpb.OperationMetadata, error) { + var meta gamingpb.OperationMetadata + if err := op.lro.Metadata(&meta); err == longrunning.ErrNoMetadata { + return nil, nil + } else if err != nil { + return nil, err + } + return &meta, nil +} + +// Done reports whether the long-running operation has completed. +func (op *DeleteGameServerConfigOperation) Done() bool { + return op.lro.Done() +} + +// Name returns the name of the long-running operation. +// The name is assigned by the server and is unique within the service from which the operation is created. +func (op *DeleteGameServerConfigOperation) Name() string { + return op.lro.Name() +} + +// GameServerConfigIterator manages a stream of *gamingpb.GameServerConfig. +type GameServerConfigIterator struct { + items []*gamingpb.GameServerConfig + pageInfo *iterator.PageInfo + nextFunc func() error + + // Response is the raw response for the current page. + // It must be cast to the RPC response type. + // Calling Next() or InternalFetch() updates this value. + Response interface{} + + // 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 []*gamingpb.GameServerConfig, nextPageToken string, err error) +} + +// PageInfo supports pagination. See the google.golang.org/api/iterator package for details. +func (it *GameServerConfigIterator) 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 *GameServerConfigIterator) Next() (*gamingpb.GameServerConfig, error) { + var item *gamingpb.GameServerConfig + if err := it.nextFunc(); err != nil { + return item, err + } + item = it.items[0] + it.items = it.items[1:] + return item, nil +} + +func (it *GameServerConfigIterator) bufLen() int { + return len(it.items) +} + +func (it *GameServerConfigIterator) takeBuf() interface{} { + b := it.items + it.items = nil + return b +} diff --git a/gaming/apiv1/game_server_configs_client_example_test.go b/gaming/apiv1/game_server_configs_client_example_test.go new file mode 100644 index 00000000000..cec82640abf --- /dev/null +++ b/gaming/apiv1/game_server_configs_client_example_test.go @@ -0,0 +1,130 @@ +// Copyright 2020 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 gaming_test + +import ( + "context" + + gaming "cloud.google.com/go/gaming/apiv1" + "google.golang.org/api/iterator" + gamingpb "google.golang.org/genproto/googleapis/cloud/gaming/v1" +) + +func ExampleNewGameServerConfigsClient() { + ctx := context.Background() + c, err := gaming.NewGameServerConfigsClient(ctx) + if err != nil { + // TODO: Handle error. + } + // TODO: Use client. + _ = c +} + +func ExampleGameServerConfigsClient_ListGameServerConfigs() { + // import gamingpb "google.golang.org/genproto/googleapis/cloud/gaming/v1" + // import "google.golang.org/api/iterator" + + ctx := context.Background() + c, err := gaming.NewGameServerConfigsClient(ctx) + if err != nil { + // TODO: Handle error. + } + + req := &gamingpb.ListGameServerConfigsRequest{ + // TODO: Fill request struct fields. + } + it := c.ListGameServerConfigs(ctx, req) + for { + resp, err := it.Next() + if err == iterator.Done { + break + } + if err != nil { + // TODO: Handle error. + } + // TODO: Use resp. + _ = resp + } +} + +func ExampleGameServerConfigsClient_GetGameServerConfig() { + // import gamingpb "google.golang.org/genproto/googleapis/cloud/gaming/v1" + + ctx := context.Background() + c, err := gaming.NewGameServerConfigsClient(ctx) + if err != nil { + // TODO: Handle error. + } + + req := &gamingpb.GetGameServerConfigRequest{ + // TODO: Fill request struct fields. + } + resp, err := c.GetGameServerConfig(ctx, req) + if err != nil { + // TODO: Handle error. + } + // TODO: Use resp. + _ = resp +} + +func ExampleGameServerConfigsClient_CreateGameServerConfig() { + // import gamingpb "google.golang.org/genproto/googleapis/cloud/gaming/v1" + + ctx := context.Background() + c, err := gaming.NewGameServerConfigsClient(ctx) + if err != nil { + // TODO: Handle error. + } + + req := &gamingpb.CreateGameServerConfigRequest{ + // TODO: Fill request struct fields. + } + op, err := c.CreateGameServerConfig(ctx, req) + if err != nil { + // TODO: Handle error. + } + + resp, err := op.Wait(ctx) + if err != nil { + // TODO: Handle error. + } + // TODO: Use resp. + _ = resp +} + +func ExampleGameServerConfigsClient_DeleteGameServerConfig() { + // import gamingpb "google.golang.org/genproto/googleapis/cloud/gaming/v1" + + ctx := context.Background() + c, err := gaming.NewGameServerConfigsClient(ctx) + if err != nil { + // TODO: Handle error. + } + + req := &gamingpb.DeleteGameServerConfigRequest{ + // TODO: Fill request struct fields. + } + op, err := c.DeleteGameServerConfig(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) + if err != nil { + // TODO: Handle error. + } +} diff --git a/gaming/apiv1/game_server_deployments_client.go b/gaming/apiv1/game_server_deployments_client.go new file mode 100644 index 00000000000..95519e26204 --- /dev/null +++ b/gaming/apiv1/game_server_deployments_client.go @@ -0,0 +1,716 @@ +// Copyright 2020 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 gaming + +import ( + "context" + "fmt" + "math" + "net/url" + "time" + + "cloud.google.com/go/longrunning" + lroauto "cloud.google.com/go/longrunning/autogen" + "github.com/golang/protobuf/proto" + gax "github.com/googleapis/gax-go/v2" + "google.golang.org/api/iterator" + "google.golang.org/api/option" + gtransport "google.golang.org/api/transport/grpc" + gamingpb "google.golang.org/genproto/googleapis/cloud/gaming/v1" + longrunningpb "google.golang.org/genproto/googleapis/longrunning" + "google.golang.org/grpc" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/metadata" +) + +var newGameServerDeploymentsClientHook clientHook + +// GameServerDeploymentsCallOptions contains the retry settings for each method of GameServerDeploymentsClient. +type GameServerDeploymentsCallOptions struct { + ListGameServerDeployments []gax.CallOption + GetGameServerDeployment []gax.CallOption + CreateGameServerDeployment []gax.CallOption + DeleteGameServerDeployment []gax.CallOption + UpdateGameServerDeployment []gax.CallOption + GetGameServerDeploymentRollout []gax.CallOption + UpdateGameServerDeploymentRollout []gax.CallOption + PreviewGameServerDeploymentRollout []gax.CallOption + FetchDeploymentState []gax.CallOption +} + +func defaultGameServerDeploymentsClientOptions() []option.ClientOption { + return []option.ClientOption{ + option.WithEndpoint("gameservices.googleapis.com:443"), + option.WithGRPCDialOption(grpc.WithDisableServiceConfig()), + option.WithScopes(DefaultAuthScopes()...), + option.WithGRPCDialOption(grpc.WithDefaultCallOptions( + grpc.MaxCallRecvMsgSize(math.MaxInt32))), + } +} + +func defaultGameServerDeploymentsCallOptions() *GameServerDeploymentsCallOptions { + return &GameServerDeploymentsCallOptions{ + ListGameServerDeployments: []gax.CallOption{ + gax.WithRetry(func() gax.Retryer { + return gax.OnCodes([]codes.Code{ + codes.Unavailable, + }, gax.Backoff{ + Initial: 1000 * time.Millisecond, + Max: 10000 * time.Millisecond, + Multiplier: 1.30, + }) + }), + }, + GetGameServerDeployment: []gax.CallOption{ + gax.WithRetry(func() gax.Retryer { + return gax.OnCodes([]codes.Code{ + codes.Unavailable, + }, gax.Backoff{ + Initial: 1000 * time.Millisecond, + Max: 10000 * time.Millisecond, + Multiplier: 1.30, + }) + }), + }, + CreateGameServerDeployment: []gax.CallOption{}, + DeleteGameServerDeployment: []gax.CallOption{}, + UpdateGameServerDeployment: []gax.CallOption{}, + GetGameServerDeploymentRollout: []gax.CallOption{ + gax.WithRetry(func() gax.Retryer { + return gax.OnCodes([]codes.Code{ + codes.Unavailable, + }, gax.Backoff{ + Initial: 1000 * time.Millisecond, + Max: 10000 * time.Millisecond, + Multiplier: 1.30, + }) + }), + }, + UpdateGameServerDeploymentRollout: []gax.CallOption{}, + PreviewGameServerDeploymentRollout: []gax.CallOption{ + gax.WithRetry(func() gax.Retryer { + return gax.OnCodes([]codes.Code{ + codes.Unavailable, + }, gax.Backoff{ + Initial: 1000 * time.Millisecond, + Max: 10000 * time.Millisecond, + Multiplier: 1.30, + }) + }), + }, + FetchDeploymentState: []gax.CallOption{ + gax.WithRetry(func() gax.Retryer { + return gax.OnCodes([]codes.Code{ + codes.Unavailable, + }, gax.Backoff{ + Initial: 1000 * time.Millisecond, + Max: 10000 * time.Millisecond, + Multiplier: 1.30, + }) + }), + }, + } +} + +// GameServerDeploymentsClient is a client for interacting with . +// +// Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls. +type GameServerDeploymentsClient struct { + // Connection pool of gRPC connections to the service. + connPool gtransport.ConnPool + + // The gRPC API client. + gameServerDeploymentsClient gamingpb.GameServerDeploymentsServiceClient + + // LROClient is used internally to handle longrunning operations. + // It is exposed so that its CallOptions can be modified if required. + // Users should not Close this client. + LROClient *lroauto.OperationsClient + + // The call options for this service. + CallOptions *GameServerDeploymentsCallOptions + + // The x-goog-* metadata to be sent with each request. + xGoogMetadata metadata.MD +} + +// NewGameServerDeploymentsClient creates a new game server deployments service client. +// +// The game server deployment is used to control the deployment of Agones +// fleets. +func NewGameServerDeploymentsClient(ctx context.Context, opts ...option.ClientOption) (*GameServerDeploymentsClient, error) { + clientOpts := defaultGameServerDeploymentsClientOptions() + + if newGameServerDeploymentsClientHook != nil { + hookOpts, err := newGameServerDeploymentsClientHook(ctx, clientHookParams{}) + if err != nil { + return nil, err + } + clientOpts = append(clientOpts, hookOpts...) + } + + connPool, err := gtransport.DialPool(ctx, append(clientOpts, opts...)...) + if err != nil { + return nil, err + } + c := &GameServerDeploymentsClient{ + connPool: connPool, + CallOptions: defaultGameServerDeploymentsCallOptions(), + + gameServerDeploymentsClient: gamingpb.NewGameServerDeploymentsServiceClient(connPool), + } + c.setGoogleClientInfo() + + c.LROClient, err = lroauto.NewOperationsClient(ctx, gtransport.WithConnPool(connPool)) + if err != nil { + // This error "should not happen", since we are just reusing old connection pool + // and never actually need to dial. + // If this does happen, we could leak connp. However, we cannot close conn: + // If the user invoked the constructor with option.WithGRPCConn, + // we would close a connection that's still in use. + // TODO: investigate error conditions. + return nil, err + } + return c, nil +} + +// Connection returns a connection to the API service. +// +// Deprecated. +func (c *GameServerDeploymentsClient) 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 *GameServerDeploymentsClient) 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 *GameServerDeploymentsClient) 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...)) +} + +// ListGameServerDeployments lists game server deployments in a given project and location. +func (c *GameServerDeploymentsClient) ListGameServerDeployments(ctx context.Context, req *gamingpb.ListGameServerDeploymentsRequest, opts ...gax.CallOption) *GameServerDeploymentIterator { + md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))) + ctx = insertMetadata(ctx, c.xGoogMetadata, md) + opts = append(c.CallOptions.ListGameServerDeployments[0:len(c.CallOptions.ListGameServerDeployments):len(c.CallOptions.ListGameServerDeployments)], opts...) + it := &GameServerDeploymentIterator{} + req = proto.Clone(req).(*gamingpb.ListGameServerDeploymentsRequest) + it.InternalFetch = func(pageSize int, pageToken string) ([]*gamingpb.GameServerDeployment, string, error) { + var resp *gamingpb.ListGameServerDeploymentsResponse + 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.gameServerDeploymentsClient.ListGameServerDeployments(ctx, req, settings.GRPC...) + return err + }, opts...) + if err != nil { + return nil, "", err + } + + it.Response = resp + return resp.GameServerDeployments, 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) + it.pageInfo.MaxSize = int(req.PageSize) + it.pageInfo.Token = req.PageToken + return it +} + +// GetGameServerDeployment gets details of a single game server deployment. +func (c *GameServerDeploymentsClient) GetGameServerDeployment(ctx context.Context, req *gamingpb.GetGameServerDeploymentRequest, opts ...gax.CallOption) (*gamingpb.GameServerDeployment, error) { + md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))) + ctx = insertMetadata(ctx, c.xGoogMetadata, md) + opts = append(c.CallOptions.GetGameServerDeployment[0:len(c.CallOptions.GetGameServerDeployment):len(c.CallOptions.GetGameServerDeployment)], opts...) + var resp *gamingpb.GameServerDeployment + err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { + var err error + resp, err = c.gameServerDeploymentsClient.GetGameServerDeployment(ctx, req, settings.GRPC...) + return err + }, opts...) + if err != nil { + return nil, err + } + return resp, nil +} + +// CreateGameServerDeployment creates a new game server deployment in a given project and location. +func (c *GameServerDeploymentsClient) CreateGameServerDeployment(ctx context.Context, req *gamingpb.CreateGameServerDeploymentRequest, opts ...gax.CallOption) (*CreateGameServerDeploymentOperation, error) { + md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))) + ctx = insertMetadata(ctx, c.xGoogMetadata, md) + opts = append(c.CallOptions.CreateGameServerDeployment[0:len(c.CallOptions.CreateGameServerDeployment):len(c.CallOptions.CreateGameServerDeployment)], opts...) + var resp *longrunningpb.Operation + err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { + var err error + resp, err = c.gameServerDeploymentsClient.CreateGameServerDeployment(ctx, req, settings.GRPC...) + return err + }, opts...) + if err != nil { + return nil, err + } + return &CreateGameServerDeploymentOperation{ + lro: longrunning.InternalNewOperation(c.LROClient, resp), + }, nil +} + +// DeleteGameServerDeployment deletes a single game server deployment. +func (c *GameServerDeploymentsClient) DeleteGameServerDeployment(ctx context.Context, req *gamingpb.DeleteGameServerDeploymentRequest, opts ...gax.CallOption) (*DeleteGameServerDeploymentOperation, error) { + md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))) + ctx = insertMetadata(ctx, c.xGoogMetadata, md) + opts = append(c.CallOptions.DeleteGameServerDeployment[0:len(c.CallOptions.DeleteGameServerDeployment):len(c.CallOptions.DeleteGameServerDeployment)], opts...) + var resp *longrunningpb.Operation + err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { + var err error + resp, err = c.gameServerDeploymentsClient.DeleteGameServerDeployment(ctx, req, settings.GRPC...) + return err + }, opts...) + if err != nil { + return nil, err + } + return &DeleteGameServerDeploymentOperation{ + lro: longrunning.InternalNewOperation(c.LROClient, resp), + }, nil +} + +// UpdateGameServerDeployment patches a game server deployment. +func (c *GameServerDeploymentsClient) UpdateGameServerDeployment(ctx context.Context, req *gamingpb.UpdateGameServerDeploymentRequest, opts ...gax.CallOption) (*UpdateGameServerDeploymentOperation, error) { + md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "game_server_deployment.name", url.QueryEscape(req.GetGameServerDeployment().GetName()))) + ctx = insertMetadata(ctx, c.xGoogMetadata, md) + opts = append(c.CallOptions.UpdateGameServerDeployment[0:len(c.CallOptions.UpdateGameServerDeployment):len(c.CallOptions.UpdateGameServerDeployment)], opts...) + var resp *longrunningpb.Operation + err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { + var err error + resp, err = c.gameServerDeploymentsClient.UpdateGameServerDeployment(ctx, req, settings.GRPC...) + return err + }, opts...) + if err != nil { + return nil, err + } + return &UpdateGameServerDeploymentOperation{ + lro: longrunning.InternalNewOperation(c.LROClient, resp), + }, nil +} + +// GetGameServerDeploymentRollout gets details a single game server deployment rollout. +func (c *GameServerDeploymentsClient) GetGameServerDeploymentRollout(ctx context.Context, req *gamingpb.GetGameServerDeploymentRolloutRequest, opts ...gax.CallOption) (*gamingpb.GameServerDeploymentRollout, error) { + md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))) + ctx = insertMetadata(ctx, c.xGoogMetadata, md) + opts = append(c.CallOptions.GetGameServerDeploymentRollout[0:len(c.CallOptions.GetGameServerDeploymentRollout):len(c.CallOptions.GetGameServerDeploymentRollout)], opts...) + var resp *gamingpb.GameServerDeploymentRollout + err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { + var err error + resp, err = c.gameServerDeploymentsClient.GetGameServerDeploymentRollout(ctx, req, settings.GRPC...) + return err + }, opts...) + if err != nil { + return nil, err + } + return resp, nil +} + +// UpdateGameServerDeploymentRollout patches a single game server deployment rollout. +// The method will not return an error if the update does not affect any +// existing realms. For example - if the default_game_server_config is changed +// but all existing realms use the override, that is valid. Similarly, if a +// non existing realm is explicitly called out in game_server_config_overrides +// field, that will also not result in an error. +func (c *GameServerDeploymentsClient) UpdateGameServerDeploymentRollout(ctx context.Context, req *gamingpb.UpdateGameServerDeploymentRolloutRequest, opts ...gax.CallOption) (*UpdateGameServerDeploymentRolloutOperation, error) { + md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "rollout.name", url.QueryEscape(req.GetRollout().GetName()))) + ctx = insertMetadata(ctx, c.xGoogMetadata, md) + opts = append(c.CallOptions.UpdateGameServerDeploymentRollout[0:len(c.CallOptions.UpdateGameServerDeploymentRollout):len(c.CallOptions.UpdateGameServerDeploymentRollout)], opts...) + var resp *longrunningpb.Operation + err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { + var err error + resp, err = c.gameServerDeploymentsClient.UpdateGameServerDeploymentRollout(ctx, req, settings.GRPC...) + return err + }, opts...) + if err != nil { + return nil, err + } + return &UpdateGameServerDeploymentRolloutOperation{ + lro: longrunning.InternalNewOperation(c.LROClient, resp), + }, nil +} + +// PreviewGameServerDeploymentRollout previews the game server deployment rollout. This API does not mutate the +// rollout resource. +func (c *GameServerDeploymentsClient) PreviewGameServerDeploymentRollout(ctx context.Context, req *gamingpb.PreviewGameServerDeploymentRolloutRequest, opts ...gax.CallOption) (*gamingpb.PreviewGameServerDeploymentRolloutResponse, error) { + md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "rollout.name", url.QueryEscape(req.GetRollout().GetName()))) + ctx = insertMetadata(ctx, c.xGoogMetadata, md) + opts = append(c.CallOptions.PreviewGameServerDeploymentRollout[0:len(c.CallOptions.PreviewGameServerDeploymentRollout):len(c.CallOptions.PreviewGameServerDeploymentRollout)], opts...) + var resp *gamingpb.PreviewGameServerDeploymentRolloutResponse + err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { + var err error + resp, err = c.gameServerDeploymentsClient.PreviewGameServerDeploymentRollout(ctx, req, settings.GRPC...) + return err + }, opts...) + if err != nil { + return nil, err + } + return resp, nil +} + +// FetchDeploymentState retrieves information about the current state of the game server +// deployment. Gathers all the Agones fleets and Agones autoscalers, +// including fleets running an older version of the game server deployment. +func (c *GameServerDeploymentsClient) FetchDeploymentState(ctx context.Context, req *gamingpb.FetchDeploymentStateRequest, opts ...gax.CallOption) (*gamingpb.FetchDeploymentStateResponse, error) { + md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))) + ctx = insertMetadata(ctx, c.xGoogMetadata, md) + opts = append(c.CallOptions.FetchDeploymentState[0:len(c.CallOptions.FetchDeploymentState):len(c.CallOptions.FetchDeploymentState)], opts...) + var resp *gamingpb.FetchDeploymentStateResponse + err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { + var err error + resp, err = c.gameServerDeploymentsClient.FetchDeploymentState(ctx, req, settings.GRPC...) + return err + }, opts...) + if err != nil { + return nil, err + } + return resp, nil +} + +// CreateGameServerDeploymentOperation manages a long-running operation from CreateGameServerDeployment. +type CreateGameServerDeploymentOperation struct { + lro *longrunning.Operation +} + +// CreateGameServerDeploymentOperation returns a new CreateGameServerDeploymentOperation from a given name. +// The name must be that of a previously created CreateGameServerDeploymentOperation, possibly from a different process. +func (c *GameServerDeploymentsClient) CreateGameServerDeploymentOperation(name string) *CreateGameServerDeploymentOperation { + return &CreateGameServerDeploymentOperation{ + lro: longrunning.InternalNewOperation(c.LROClient, &longrunningpb.Operation{Name: name}), + } +} + +// Wait blocks until the long-running operation is completed, returning the response and any errors encountered. +// +// See documentation of Poll for error-handling information. +func (op *CreateGameServerDeploymentOperation) Wait(ctx context.Context, opts ...gax.CallOption) (*gamingpb.GameServerDeployment, error) { + var resp gamingpb.GameServerDeployment + if err := op.lro.WaitWithInterval(ctx, &resp, time.Minute, opts...); err != nil { + return nil, err + } + return &resp, nil +} + +// Poll fetches the latest state of the long-running operation. +// +// Poll also fetches the latest metadata, which can be retrieved by Metadata. +// +// If Poll fails, the error is returned and op is unmodified. If Poll succeeds and +// the operation has completed with failure, the error is returned and op.Done will return true. +// If Poll succeeds and the operation has completed successfully, +// op.Done will return true, and the response of the operation is returned. +// If Poll succeeds and the operation has not completed, the returned response and error are both nil. +func (op *CreateGameServerDeploymentOperation) Poll(ctx context.Context, opts ...gax.CallOption) (*gamingpb.GameServerDeployment, error) { + var resp gamingpb.GameServerDeployment + if err := op.lro.Poll(ctx, &resp, opts...); err != nil { + return nil, err + } + if !op.Done() { + return nil, nil + } + return &resp, nil +} + +// Metadata returns metadata associated with the long-running operation. +// Metadata itself does not contact the server, but Poll does. +// To get the latest metadata, call this method after a successful call to Poll. +// If the metadata is not available, the returned metadata and error are both nil. +func (op *CreateGameServerDeploymentOperation) Metadata() (*gamingpb.OperationMetadata, error) { + var meta gamingpb.OperationMetadata + if err := op.lro.Metadata(&meta); err == longrunning.ErrNoMetadata { + return nil, nil + } else if err != nil { + return nil, err + } + return &meta, nil +} + +// Done reports whether the long-running operation has completed. +func (op *CreateGameServerDeploymentOperation) Done() bool { + return op.lro.Done() +} + +// Name returns the name of the long-running operation. +// The name is assigned by the server and is unique within the service from which the operation is created. +func (op *CreateGameServerDeploymentOperation) Name() string { + return op.lro.Name() +} + +// DeleteGameServerDeploymentOperation manages a long-running operation from DeleteGameServerDeployment. +type DeleteGameServerDeploymentOperation struct { + lro *longrunning.Operation +} + +// DeleteGameServerDeploymentOperation returns a new DeleteGameServerDeploymentOperation from a given name. +// The name must be that of a previously created DeleteGameServerDeploymentOperation, possibly from a different process. +func (c *GameServerDeploymentsClient) DeleteGameServerDeploymentOperation(name string) *DeleteGameServerDeploymentOperation { + return &DeleteGameServerDeploymentOperation{ + lro: longrunning.InternalNewOperation(c.LROClient, &longrunningpb.Operation{Name: name}), + } +} + +// Wait blocks until the long-running operation is completed, returning the response and any errors encountered. +// +// See documentation of Poll for error-handling information. +func (op *DeleteGameServerDeploymentOperation) Wait(ctx context.Context, opts ...gax.CallOption) error { + return op.lro.WaitWithInterval(ctx, nil, time.Minute, opts...) +} + +// Poll fetches the latest state of the long-running operation. +// +// Poll also fetches the latest metadata, which can be retrieved by Metadata. +// +// If Poll fails, the error is returned and op is unmodified. If Poll succeeds and +// the operation has completed with failure, the error is returned and op.Done will return true. +// If Poll succeeds and the operation has completed successfully, +// op.Done will return true, and the response of the operation is returned. +// If Poll succeeds and the operation has not completed, the returned response and error are both nil. +func (op *DeleteGameServerDeploymentOperation) Poll(ctx context.Context, opts ...gax.CallOption) error { + return op.lro.Poll(ctx, nil, opts...) +} + +// Metadata returns metadata associated with the long-running operation. +// Metadata itself does not contact the server, but Poll does. +// To get the latest metadata, call this method after a successful call to Poll. +// If the metadata is not available, the returned metadata and error are both nil. +func (op *DeleteGameServerDeploymentOperation) Metadata() (*gamingpb.OperationMetadata, error) { + var meta gamingpb.OperationMetadata + if err := op.lro.Metadata(&meta); err == longrunning.ErrNoMetadata { + return nil, nil + } else if err != nil { + return nil, err + } + return &meta, nil +} + +// Done reports whether the long-running operation has completed. +func (op *DeleteGameServerDeploymentOperation) Done() bool { + return op.lro.Done() +} + +// Name returns the name of the long-running operation. +// The name is assigned by the server and is unique within the service from which the operation is created. +func (op *DeleteGameServerDeploymentOperation) Name() string { + return op.lro.Name() +} + +// UpdateGameServerDeploymentOperation manages a long-running operation from UpdateGameServerDeployment. +type UpdateGameServerDeploymentOperation struct { + lro *longrunning.Operation +} + +// UpdateGameServerDeploymentOperation returns a new UpdateGameServerDeploymentOperation from a given name. +// The name must be that of a previously created UpdateGameServerDeploymentOperation, possibly from a different process. +func (c *GameServerDeploymentsClient) UpdateGameServerDeploymentOperation(name string) *UpdateGameServerDeploymentOperation { + return &UpdateGameServerDeploymentOperation{ + lro: longrunning.InternalNewOperation(c.LROClient, &longrunningpb.Operation{Name: name}), + } +} + +// Wait blocks until the long-running operation is completed, returning the response and any errors encountered. +// +// See documentation of Poll for error-handling information. +func (op *UpdateGameServerDeploymentOperation) Wait(ctx context.Context, opts ...gax.CallOption) (*gamingpb.GameServerDeployment, error) { + var resp gamingpb.GameServerDeployment + if err := op.lro.WaitWithInterval(ctx, &resp, time.Minute, opts...); err != nil { + return nil, err + } + return &resp, nil +} + +// Poll fetches the latest state of the long-running operation. +// +// Poll also fetches the latest metadata, which can be retrieved by Metadata. +// +// If Poll fails, the error is returned and op is unmodified. If Poll succeeds and +// the operation has completed with failure, the error is returned and op.Done will return true. +// If Poll succeeds and the operation has completed successfully, +// op.Done will return true, and the response of the operation is returned. +// If Poll succeeds and the operation has not completed, the returned response and error are both nil. +func (op *UpdateGameServerDeploymentOperation) Poll(ctx context.Context, opts ...gax.CallOption) (*gamingpb.GameServerDeployment, error) { + var resp gamingpb.GameServerDeployment + if err := op.lro.Poll(ctx, &resp, opts...); err != nil { + return nil, err + } + if !op.Done() { + return nil, nil + } + return &resp, nil +} + +// Metadata returns metadata associated with the long-running operation. +// Metadata itself does not contact the server, but Poll does. +// To get the latest metadata, call this method after a successful call to Poll. +// If the metadata is not available, the returned metadata and error are both nil. +func (op *UpdateGameServerDeploymentOperation) Metadata() (*gamingpb.OperationMetadata, error) { + var meta gamingpb.OperationMetadata + if err := op.lro.Metadata(&meta); err == longrunning.ErrNoMetadata { + return nil, nil + } else if err != nil { + return nil, err + } + return &meta, nil +} + +// Done reports whether the long-running operation has completed. +func (op *UpdateGameServerDeploymentOperation) Done() bool { + return op.lro.Done() +} + +// Name returns the name of the long-running operation. +// The name is assigned by the server and is unique within the service from which the operation is created. +func (op *UpdateGameServerDeploymentOperation) Name() string { + return op.lro.Name() +} + +// UpdateGameServerDeploymentRolloutOperation manages a long-running operation from UpdateGameServerDeploymentRollout. +type UpdateGameServerDeploymentRolloutOperation struct { + lro *longrunning.Operation +} + +// UpdateGameServerDeploymentRolloutOperation returns a new UpdateGameServerDeploymentRolloutOperation from a given name. +// The name must be that of a previously created UpdateGameServerDeploymentRolloutOperation, possibly from a different process. +func (c *GameServerDeploymentsClient) UpdateGameServerDeploymentRolloutOperation(name string) *UpdateGameServerDeploymentRolloutOperation { + return &UpdateGameServerDeploymentRolloutOperation{ + lro: longrunning.InternalNewOperation(c.LROClient, &longrunningpb.Operation{Name: name}), + } +} + +// Wait blocks until the long-running operation is completed, returning the response and any errors encountered. +// +// See documentation of Poll for error-handling information. +func (op *UpdateGameServerDeploymentRolloutOperation) Wait(ctx context.Context, opts ...gax.CallOption) (*gamingpb.GameServerDeployment, error) { + var resp gamingpb.GameServerDeployment + if err := op.lro.WaitWithInterval(ctx, &resp, time.Minute, opts...); err != nil { + return nil, err + } + return &resp, nil +} + +// Poll fetches the latest state of the long-running operation. +// +// Poll also fetches the latest metadata, which can be retrieved by Metadata. +// +// If Poll fails, the error is returned and op is unmodified. If Poll succeeds and +// the operation has completed with failure, the error is returned and op.Done will return true. +// If Poll succeeds and the operation has completed successfully, +// op.Done will return true, and the response of the operation is returned. +// If Poll succeeds and the operation has not completed, the returned response and error are both nil. +func (op *UpdateGameServerDeploymentRolloutOperation) Poll(ctx context.Context, opts ...gax.CallOption) (*gamingpb.GameServerDeployment, error) { + var resp gamingpb.GameServerDeployment + if err := op.lro.Poll(ctx, &resp, opts...); err != nil { + return nil, err + } + if !op.Done() { + return nil, nil + } + return &resp, nil +} + +// Metadata returns metadata associated with the long-running operation. +// Metadata itself does not contact the server, but Poll does. +// To get the latest metadata, call this method after a successful call to Poll. +// If the metadata is not available, the returned metadata and error are both nil. +func (op *UpdateGameServerDeploymentRolloutOperation) Metadata() (*gamingpb.OperationMetadata, error) { + var meta gamingpb.OperationMetadata + if err := op.lro.Metadata(&meta); err == longrunning.ErrNoMetadata { + return nil, nil + } else if err != nil { + return nil, err + } + return &meta, nil +} + +// Done reports whether the long-running operation has completed. +func (op *UpdateGameServerDeploymentRolloutOperation) Done() bool { + return op.lro.Done() +} + +// Name returns the name of the long-running operation. +// The name is assigned by the server and is unique within the service from which the operation is created. +func (op *UpdateGameServerDeploymentRolloutOperation) Name() string { + return op.lro.Name() +} + +// GameServerDeploymentIterator manages a stream of *gamingpb.GameServerDeployment. +type GameServerDeploymentIterator struct { + items []*gamingpb.GameServerDeployment + pageInfo *iterator.PageInfo + nextFunc func() error + + // Response is the raw response for the current page. + // It must be cast to the RPC response type. + // Calling Next() or InternalFetch() updates this value. + Response interface{} + + // 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 []*gamingpb.GameServerDeployment, nextPageToken string, err error) +} + +// PageInfo supports pagination. See the google.golang.org/api/iterator package for details. +func (it *GameServerDeploymentIterator) 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 *GameServerDeploymentIterator) Next() (*gamingpb.GameServerDeployment, error) { + var item *gamingpb.GameServerDeployment + if err := it.nextFunc(); err != nil { + return item, err + } + item = it.items[0] + it.items = it.items[1:] + return item, nil +} + +func (it *GameServerDeploymentIterator) bufLen() int { + return len(it.items) +} + +func (it *GameServerDeploymentIterator) takeBuf() interface{} { + b := it.items + it.items = nil + return b +} diff --git a/gaming/apiv1/game_server_deployments_client_example_test.go b/gaming/apiv1/game_server_deployments_client_example_test.go new file mode 100644 index 00000000000..424dd85a511 --- /dev/null +++ b/gaming/apiv1/game_server_deployments_client_example_test.go @@ -0,0 +1,240 @@ +// Copyright 2020 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 gaming_test + +import ( + "context" + + gaming "cloud.google.com/go/gaming/apiv1" + "google.golang.org/api/iterator" + gamingpb "google.golang.org/genproto/googleapis/cloud/gaming/v1" +) + +func ExampleNewGameServerDeploymentsClient() { + ctx := context.Background() + c, err := gaming.NewGameServerDeploymentsClient(ctx) + if err != nil { + // TODO: Handle error. + } + // TODO: Use client. + _ = c +} + +func ExampleGameServerDeploymentsClient_ListGameServerDeployments() { + // import gamingpb "google.golang.org/genproto/googleapis/cloud/gaming/v1" + // import "google.golang.org/api/iterator" + + ctx := context.Background() + c, err := gaming.NewGameServerDeploymentsClient(ctx) + if err != nil { + // TODO: Handle error. + } + + req := &gamingpb.ListGameServerDeploymentsRequest{ + // TODO: Fill request struct fields. + } + it := c.ListGameServerDeployments(ctx, req) + for { + resp, err := it.Next() + if err == iterator.Done { + break + } + if err != nil { + // TODO: Handle error. + } + // TODO: Use resp. + _ = resp + } +} + +func ExampleGameServerDeploymentsClient_GetGameServerDeployment() { + // import gamingpb "google.golang.org/genproto/googleapis/cloud/gaming/v1" + + ctx := context.Background() + c, err := gaming.NewGameServerDeploymentsClient(ctx) + if err != nil { + // TODO: Handle error. + } + + req := &gamingpb.GetGameServerDeploymentRequest{ + // TODO: Fill request struct fields. + } + resp, err := c.GetGameServerDeployment(ctx, req) + if err != nil { + // TODO: Handle error. + } + // TODO: Use resp. + _ = resp +} + +func ExampleGameServerDeploymentsClient_CreateGameServerDeployment() { + // import gamingpb "google.golang.org/genproto/googleapis/cloud/gaming/v1" + + ctx := context.Background() + c, err := gaming.NewGameServerDeploymentsClient(ctx) + if err != nil { + // TODO: Handle error. + } + + req := &gamingpb.CreateGameServerDeploymentRequest{ + // TODO: Fill request struct fields. + } + op, err := c.CreateGameServerDeployment(ctx, req) + if err != nil { + // TODO: Handle error. + } + + resp, err := op.Wait(ctx) + if err != nil { + // TODO: Handle error. + } + // TODO: Use resp. + _ = resp +} + +func ExampleGameServerDeploymentsClient_DeleteGameServerDeployment() { + // import gamingpb "google.golang.org/genproto/googleapis/cloud/gaming/v1" + + ctx := context.Background() + c, err := gaming.NewGameServerDeploymentsClient(ctx) + if err != nil { + // TODO: Handle error. + } + + req := &gamingpb.DeleteGameServerDeploymentRequest{ + // TODO: Fill request struct fields. + } + op, err := c.DeleteGameServerDeployment(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) + if err != nil { + // TODO: Handle error. + } +} + +func ExampleGameServerDeploymentsClient_UpdateGameServerDeployment() { + // import gamingpb "google.golang.org/genproto/googleapis/cloud/gaming/v1" + + ctx := context.Background() + c, err := gaming.NewGameServerDeploymentsClient(ctx) + if err != nil { + // TODO: Handle error. + } + + req := &gamingpb.UpdateGameServerDeploymentRequest{ + // TODO: Fill request struct fields. + } + op, err := c.UpdateGameServerDeployment(ctx, req) + if err != nil { + // TODO: Handle error. + } + + resp, err := op.Wait(ctx) + if err != nil { + // TODO: Handle error. + } + // TODO: Use resp. + _ = resp +} + +func ExampleGameServerDeploymentsClient_GetGameServerDeploymentRollout() { + // import gamingpb "google.golang.org/genproto/googleapis/cloud/gaming/v1" + + ctx := context.Background() + c, err := gaming.NewGameServerDeploymentsClient(ctx) + if err != nil { + // TODO: Handle error. + } + + req := &gamingpb.GetGameServerDeploymentRolloutRequest{ + // TODO: Fill request struct fields. + } + resp, err := c.GetGameServerDeploymentRollout(ctx, req) + if err != nil { + // TODO: Handle error. + } + // TODO: Use resp. + _ = resp +} + +func ExampleGameServerDeploymentsClient_UpdateGameServerDeploymentRollout() { + // import gamingpb "google.golang.org/genproto/googleapis/cloud/gaming/v1" + + ctx := context.Background() + c, err := gaming.NewGameServerDeploymentsClient(ctx) + if err != nil { + // TODO: Handle error. + } + + req := &gamingpb.UpdateGameServerDeploymentRolloutRequest{ + // TODO: Fill request struct fields. + } + op, err := c.UpdateGameServerDeploymentRollout(ctx, req) + if err != nil { + // TODO: Handle error. + } + + resp, err := op.Wait(ctx) + if err != nil { + // TODO: Handle error. + } + // TODO: Use resp. + _ = resp +} + +func ExampleGameServerDeploymentsClient_PreviewGameServerDeploymentRollout() { + // import gamingpb "google.golang.org/genproto/googleapis/cloud/gaming/v1" + + ctx := context.Background() + c, err := gaming.NewGameServerDeploymentsClient(ctx) + if err != nil { + // TODO: Handle error. + } + + req := &gamingpb.PreviewGameServerDeploymentRolloutRequest{ + // TODO: Fill request struct fields. + } + resp, err := c.PreviewGameServerDeploymentRollout(ctx, req) + if err != nil { + // TODO: Handle error. + } + // TODO: Use resp. + _ = resp +} + +func ExampleGameServerDeploymentsClient_FetchDeploymentState() { + // import gamingpb "google.golang.org/genproto/googleapis/cloud/gaming/v1" + + ctx := context.Background() + c, err := gaming.NewGameServerDeploymentsClient(ctx) + if err != nil { + // TODO: Handle error. + } + + req := &gamingpb.FetchDeploymentStateRequest{ + // TODO: Fill request struct fields. + } + resp, err := c.FetchDeploymentState(ctx, req) + if err != nil { + // TODO: Handle error. + } + // TODO: Use resp. + _ = resp +} diff --git a/gaming/apiv1/realms_client.go b/gaming/apiv1/realms_client.go new file mode 100644 index 00000000000..b61209e9f88 --- /dev/null +++ b/gaming/apiv1/realms_client.go @@ -0,0 +1,560 @@ +// Copyright 2020 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 gaming + +import ( + "context" + "fmt" + "math" + "net/url" + "time" + + "cloud.google.com/go/longrunning" + lroauto "cloud.google.com/go/longrunning/autogen" + "github.com/golang/protobuf/proto" + gax "github.com/googleapis/gax-go/v2" + "google.golang.org/api/iterator" + "google.golang.org/api/option" + gtransport "google.golang.org/api/transport/grpc" + gamingpb "google.golang.org/genproto/googleapis/cloud/gaming/v1" + longrunningpb "google.golang.org/genproto/googleapis/longrunning" + "google.golang.org/grpc" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/metadata" +) + +var newRealmsClientHook clientHook + +// RealmsCallOptions contains the retry settings for each method of RealmsClient. +type RealmsCallOptions struct { + ListRealms []gax.CallOption + GetRealm []gax.CallOption + CreateRealm []gax.CallOption + DeleteRealm []gax.CallOption + UpdateRealm []gax.CallOption + PreviewRealmUpdate []gax.CallOption +} + +func defaultRealmsClientOptions() []option.ClientOption { + return []option.ClientOption{ + option.WithEndpoint("gameservices.googleapis.com:443"), + option.WithGRPCDialOption(grpc.WithDisableServiceConfig()), + option.WithScopes(DefaultAuthScopes()...), + option.WithGRPCDialOption(grpc.WithDefaultCallOptions( + grpc.MaxCallRecvMsgSize(math.MaxInt32))), + } +} + +func defaultRealmsCallOptions() *RealmsCallOptions { + return &RealmsCallOptions{ + ListRealms: []gax.CallOption{ + gax.WithRetry(func() gax.Retryer { + return gax.OnCodes([]codes.Code{ + codes.Unavailable, + }, gax.Backoff{ + Initial: 1000 * time.Millisecond, + Max: 10000 * time.Millisecond, + Multiplier: 1.30, + }) + }), + }, + GetRealm: []gax.CallOption{ + gax.WithRetry(func() gax.Retryer { + return gax.OnCodes([]codes.Code{ + codes.Unavailable, + }, gax.Backoff{ + Initial: 1000 * time.Millisecond, + Max: 10000 * time.Millisecond, + Multiplier: 1.30, + }) + }), + }, + CreateRealm: []gax.CallOption{}, + DeleteRealm: []gax.CallOption{}, + UpdateRealm: []gax.CallOption{}, + PreviewRealmUpdate: []gax.CallOption{ + gax.WithRetry(func() gax.Retryer { + return gax.OnCodes([]codes.Code{ + codes.Unavailable, + }, gax.Backoff{ + Initial: 1000 * time.Millisecond, + Max: 10000 * time.Millisecond, + Multiplier: 1.30, + }) + }), + }, + } +} + +// RealmsClient is a client for interacting with . +// +// Methods, except Close, may be called concurrently. However, fields must not be modified concurrently with method calls. +type RealmsClient struct { + // Connection pool of gRPC connections to the service. + connPool gtransport.ConnPool + + // The gRPC API client. + realmsClient gamingpb.RealmsServiceClient + + // LROClient is used internally to handle longrunning operations. + // It is exposed so that its CallOptions can be modified if required. + // Users should not Close this client. + LROClient *lroauto.OperationsClient + + // The call options for this service. + CallOptions *RealmsCallOptions + + // The x-goog-* metadata to be sent with each request. + xGoogMetadata metadata.MD +} + +// NewRealmsClient creates a new realms service client. +// +// A realm is a grouping of game server clusters that are considered +// interchangeable. +func NewRealmsClient(ctx context.Context, opts ...option.ClientOption) (*RealmsClient, error) { + clientOpts := defaultRealmsClientOptions() + + if newRealmsClientHook != nil { + hookOpts, err := newRealmsClientHook(ctx, clientHookParams{}) + if err != nil { + return nil, err + } + clientOpts = append(clientOpts, hookOpts...) + } + + connPool, err := gtransport.DialPool(ctx, append(clientOpts, opts...)...) + if err != nil { + return nil, err + } + c := &RealmsClient{ + connPool: connPool, + CallOptions: defaultRealmsCallOptions(), + + realmsClient: gamingpb.NewRealmsServiceClient(connPool), + } + c.setGoogleClientInfo() + + c.LROClient, err = lroauto.NewOperationsClient(ctx, gtransport.WithConnPool(connPool)) + if err != nil { + // This error "should not happen", since we are just reusing old connection pool + // and never actually need to dial. + // If this does happen, we could leak connp. However, we cannot close conn: + // If the user invoked the constructor with option.WithGRPCConn, + // we would close a connection that's still in use. + // TODO: investigate error conditions. + return nil, err + } + return c, nil +} + +// Connection returns a connection to the API service. +// +// Deprecated. +func (c *RealmsClient) 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 *RealmsClient) 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 *RealmsClient) 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...)) +} + +// ListRealms lists realms in a given project and location. +func (c *RealmsClient) ListRealms(ctx context.Context, req *gamingpb.ListRealmsRequest, opts ...gax.CallOption) *RealmIterator { + md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))) + ctx = insertMetadata(ctx, c.xGoogMetadata, md) + opts = append(c.CallOptions.ListRealms[0:len(c.CallOptions.ListRealms):len(c.CallOptions.ListRealms)], opts...) + it := &RealmIterator{} + req = proto.Clone(req).(*gamingpb.ListRealmsRequest) + it.InternalFetch = func(pageSize int, pageToken string) ([]*gamingpb.Realm, string, error) { + var resp *gamingpb.ListRealmsResponse + 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.realmsClient.ListRealms(ctx, req, settings.GRPC...) + return err + }, opts...) + if err != nil { + return nil, "", err + } + + it.Response = resp + return resp.Realms, 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) + it.pageInfo.MaxSize = int(req.PageSize) + it.pageInfo.Token = req.PageToken + return it +} + +// GetRealm gets details of a single realm. +func (c *RealmsClient) GetRealm(ctx context.Context, req *gamingpb.GetRealmRequest, opts ...gax.CallOption) (*gamingpb.Realm, error) { + md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))) + ctx = insertMetadata(ctx, c.xGoogMetadata, md) + opts = append(c.CallOptions.GetRealm[0:len(c.CallOptions.GetRealm):len(c.CallOptions.GetRealm)], opts...) + var resp *gamingpb.Realm + err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { + var err error + resp, err = c.realmsClient.GetRealm(ctx, req, settings.GRPC...) + return err + }, opts...) + if err != nil { + return nil, err + } + return resp, nil +} + +// CreateRealm creates a new realm in a given project and location. +func (c *RealmsClient) CreateRealm(ctx context.Context, req *gamingpb.CreateRealmRequest, opts ...gax.CallOption) (*CreateRealmOperation, error) { + md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "parent", url.QueryEscape(req.GetParent()))) + ctx = insertMetadata(ctx, c.xGoogMetadata, md) + opts = append(c.CallOptions.CreateRealm[0:len(c.CallOptions.CreateRealm):len(c.CallOptions.CreateRealm)], opts...) + var resp *longrunningpb.Operation + err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { + var err error + resp, err = c.realmsClient.CreateRealm(ctx, req, settings.GRPC...) + return err + }, opts...) + if err != nil { + return nil, err + } + return &CreateRealmOperation{ + lro: longrunning.InternalNewOperation(c.LROClient, resp), + }, nil +} + +// DeleteRealm deletes a single realm. +func (c *RealmsClient) DeleteRealm(ctx context.Context, req *gamingpb.DeleteRealmRequest, opts ...gax.CallOption) (*DeleteRealmOperation, error) { + md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "name", url.QueryEscape(req.GetName()))) + ctx = insertMetadata(ctx, c.xGoogMetadata, md) + opts = append(c.CallOptions.DeleteRealm[0:len(c.CallOptions.DeleteRealm):len(c.CallOptions.DeleteRealm)], opts...) + var resp *longrunningpb.Operation + err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { + var err error + resp, err = c.realmsClient.DeleteRealm(ctx, req, settings.GRPC...) + return err + }, opts...) + if err != nil { + return nil, err + } + return &DeleteRealmOperation{ + lro: longrunning.InternalNewOperation(c.LROClient, resp), + }, nil +} + +// UpdateRealm patches a single realm. +func (c *RealmsClient) UpdateRealm(ctx context.Context, req *gamingpb.UpdateRealmRequest, opts ...gax.CallOption) (*UpdateRealmOperation, error) { + md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "realm.name", url.QueryEscape(req.GetRealm().GetName()))) + ctx = insertMetadata(ctx, c.xGoogMetadata, md) + opts = append(c.CallOptions.UpdateRealm[0:len(c.CallOptions.UpdateRealm):len(c.CallOptions.UpdateRealm)], opts...) + var resp *longrunningpb.Operation + err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { + var err error + resp, err = c.realmsClient.UpdateRealm(ctx, req, settings.GRPC...) + return err + }, opts...) + if err != nil { + return nil, err + } + return &UpdateRealmOperation{ + lro: longrunning.InternalNewOperation(c.LROClient, resp), + }, nil +} + +// PreviewRealmUpdate previews patches to a single realm. +func (c *RealmsClient) PreviewRealmUpdate(ctx context.Context, req *gamingpb.PreviewRealmUpdateRequest, opts ...gax.CallOption) (*gamingpb.PreviewRealmUpdateResponse, error) { + md := metadata.Pairs("x-goog-request-params", fmt.Sprintf("%s=%v", "realm.name", url.QueryEscape(req.GetRealm().GetName()))) + ctx = insertMetadata(ctx, c.xGoogMetadata, md) + opts = append(c.CallOptions.PreviewRealmUpdate[0:len(c.CallOptions.PreviewRealmUpdate):len(c.CallOptions.PreviewRealmUpdate)], opts...) + var resp *gamingpb.PreviewRealmUpdateResponse + err := gax.Invoke(ctx, func(ctx context.Context, settings gax.CallSettings) error { + var err error + resp, err = c.realmsClient.PreviewRealmUpdate(ctx, req, settings.GRPC...) + return err + }, opts...) + if err != nil { + return nil, err + } + return resp, nil +} + +// CreateRealmOperation manages a long-running operation from CreateRealm. +type CreateRealmOperation struct { + lro *longrunning.Operation +} + +// CreateRealmOperation returns a new CreateRealmOperation from a given name. +// The name must be that of a previously created CreateRealmOperation, possibly from a different process. +func (c *RealmsClient) CreateRealmOperation(name string) *CreateRealmOperation { + return &CreateRealmOperation{ + lro: longrunning.InternalNewOperation(c.LROClient, &longrunningpb.Operation{Name: name}), + } +} + +// Wait blocks until the long-running operation is completed, returning the response and any errors encountered. +// +// See documentation of Poll for error-handling information. +func (op *CreateRealmOperation) Wait(ctx context.Context, opts ...gax.CallOption) (*gamingpb.Realm, error) { + var resp gamingpb.Realm + if err := op.lro.WaitWithInterval(ctx, &resp, time.Minute, opts...); err != nil { + return nil, err + } + return &resp, nil +} + +// Poll fetches the latest state of the long-running operation. +// +// Poll also fetches the latest metadata, which can be retrieved by Metadata. +// +// If Poll fails, the error is returned and op is unmodified. If Poll succeeds and +// the operation has completed with failure, the error is returned and op.Done will return true. +// If Poll succeeds and the operation has completed successfully, +// op.Done will return true, and the response of the operation is returned. +// If Poll succeeds and the operation has not completed, the returned response and error are both nil. +func (op *CreateRealmOperation) Poll(ctx context.Context, opts ...gax.CallOption) (*gamingpb.Realm, error) { + var resp gamingpb.Realm + if err := op.lro.Poll(ctx, &resp, opts...); err != nil { + return nil, err + } + if !op.Done() { + return nil, nil + } + return &resp, nil +} + +// Metadata returns metadata associated with the long-running operation. +// Metadata itself does not contact the server, but Poll does. +// To get the latest metadata, call this method after a successful call to Poll. +// If the metadata is not available, the returned metadata and error are both nil. +func (op *CreateRealmOperation) Metadata() (*gamingpb.OperationMetadata, error) { + var meta gamingpb.OperationMetadata + if err := op.lro.Metadata(&meta); err == longrunning.ErrNoMetadata { + return nil, nil + } else if err != nil { + return nil, err + } + return &meta, nil +} + +// Done reports whether the long-running operation has completed. +func (op *CreateRealmOperation) Done() bool { + return op.lro.Done() +} + +// Name returns the name of the long-running operation. +// The name is assigned by the server and is unique within the service from which the operation is created. +func (op *CreateRealmOperation) Name() string { + return op.lro.Name() +} + +// DeleteRealmOperation manages a long-running operation from DeleteRealm. +type DeleteRealmOperation struct { + lro *longrunning.Operation +} + +// DeleteRealmOperation returns a new DeleteRealmOperation from a given name. +// The name must be that of a previously created DeleteRealmOperation, possibly from a different process. +func (c *RealmsClient) DeleteRealmOperation(name string) *DeleteRealmOperation { + return &DeleteRealmOperation{ + lro: longrunning.InternalNewOperation(c.LROClient, &longrunningpb.Operation{Name: name}), + } +} + +// Wait blocks until the long-running operation is completed, returning the response and any errors encountered. +// +// See documentation of Poll for error-handling information. +func (op *DeleteRealmOperation) Wait(ctx context.Context, opts ...gax.CallOption) error { + return op.lro.WaitWithInterval(ctx, nil, time.Minute, opts...) +} + +// Poll fetches the latest state of the long-running operation. +// +// Poll also fetches the latest metadata, which can be retrieved by Metadata. +// +// If Poll fails, the error is returned and op is unmodified. If Poll succeeds and +// the operation has completed with failure, the error is returned and op.Done will return true. +// If Poll succeeds and the operation has completed successfully, +// op.Done will return true, and the response of the operation is returned. +// If Poll succeeds and the operation has not completed, the returned response and error are both nil. +func (op *DeleteRealmOperation) Poll(ctx context.Context, opts ...gax.CallOption) error { + return op.lro.Poll(ctx, nil, opts...) +} + +// Metadata returns metadata associated with the long-running operation. +// Metadata itself does not contact the server, but Poll does. +// To get the latest metadata, call this method after a successful call to Poll. +// If the metadata is not available, the returned metadata and error are both nil. +func (op *DeleteRealmOperation) Metadata() (*gamingpb.OperationMetadata, error) { + var meta gamingpb.OperationMetadata + if err := op.lro.Metadata(&meta); err == longrunning.ErrNoMetadata { + return nil, nil + } else if err != nil { + return nil, err + } + return &meta, nil +} + +// Done reports whether the long-running operation has completed. +func (op *DeleteRealmOperation) Done() bool { + return op.lro.Done() +} + +// Name returns the name of the long-running operation. +// The name is assigned by the server and is unique within the service from which the operation is created. +func (op *DeleteRealmOperation) Name() string { + return op.lro.Name() +} + +// UpdateRealmOperation manages a long-running operation from UpdateRealm. +type UpdateRealmOperation struct { + lro *longrunning.Operation +} + +// UpdateRealmOperation returns a new UpdateRealmOperation from a given name. +// The name must be that of a previously created UpdateRealmOperation, possibly from a different process. +func (c *RealmsClient) UpdateRealmOperation(name string) *UpdateRealmOperation { + return &UpdateRealmOperation{ + lro: longrunning.InternalNewOperation(c.LROClient, &longrunningpb.Operation{Name: name}), + } +} + +// Wait blocks until the long-running operation is completed, returning the response and any errors encountered. +// +// See documentation of Poll for error-handling information. +func (op *UpdateRealmOperation) Wait(ctx context.Context, opts ...gax.CallOption) (*gamingpb.Realm, error) { + var resp gamingpb.Realm + if err := op.lro.WaitWithInterval(ctx, &resp, time.Minute, opts...); err != nil { + return nil, err + } + return &resp, nil +} + +// Poll fetches the latest state of the long-running operation. +// +// Poll also fetches the latest metadata, which can be retrieved by Metadata. +// +// If Poll fails, the error is returned and op is unmodified. If Poll succeeds and +// the operation has completed with failure, the error is returned and op.Done will return true. +// If Poll succeeds and the operation has completed successfully, +// op.Done will return true, and the response of the operation is returned. +// If Poll succeeds and the operation has not completed, the returned response and error are both nil. +func (op *UpdateRealmOperation) Poll(ctx context.Context, opts ...gax.CallOption) (*gamingpb.Realm, error) { + var resp gamingpb.Realm + if err := op.lro.Poll(ctx, &resp, opts...); err != nil { + return nil, err + } + if !op.Done() { + return nil, nil + } + return &resp, nil +} + +// Metadata returns metadata associated with the long-running operation. +// Metadata itself does not contact the server, but Poll does. +// To get the latest metadata, call this method after a successful call to Poll. +// If the metadata is not available, the returned metadata and error are both nil. +func (op *UpdateRealmOperation) Metadata() (*gamingpb.OperationMetadata, error) { + var meta gamingpb.OperationMetadata + if err := op.lro.Metadata(&meta); err == longrunning.ErrNoMetadata { + return nil, nil + } else if err != nil { + return nil, err + } + return &meta, nil +} + +// Done reports whether the long-running operation has completed. +func (op *UpdateRealmOperation) Done() bool { + return op.lro.Done() +} + +// Name returns the name of the long-running operation. +// The name is assigned by the server and is unique within the service from which the operation is created. +func (op *UpdateRealmOperation) Name() string { + return op.lro.Name() +} + +// RealmIterator manages a stream of *gamingpb.Realm. +type RealmIterator struct { + items []*gamingpb.Realm + pageInfo *iterator.PageInfo + nextFunc func() error + + // Response is the raw response for the current page. + // It must be cast to the RPC response type. + // Calling Next() or InternalFetch() updates this value. + Response interface{} + + // 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 []*gamingpb.Realm, nextPageToken string, err error) +} + +// PageInfo supports pagination. See the google.golang.org/api/iterator package for details. +func (it *RealmIterator) 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 *RealmIterator) Next() (*gamingpb.Realm, error) { + var item *gamingpb.Realm + if err := it.nextFunc(); err != nil { + return item, err + } + item = it.items[0] + it.items = it.items[1:] + return item, nil +} + +func (it *RealmIterator) bufLen() int { + return len(it.items) +} + +func (it *RealmIterator) takeBuf() interface{} { + b := it.items + it.items = nil + return b +} diff --git a/gaming/apiv1/realms_client_example_test.go b/gaming/apiv1/realms_client_example_test.go new file mode 100644 index 00000000000..b869010b1e3 --- /dev/null +++ b/gaming/apiv1/realms_client_example_test.go @@ -0,0 +1,175 @@ +// Copyright 2020 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 gaming_test + +import ( + "context" + + gaming "cloud.google.com/go/gaming/apiv1" + "google.golang.org/api/iterator" + gamingpb "google.golang.org/genproto/googleapis/cloud/gaming/v1" +) + +func ExampleNewRealmsClient() { + ctx := context.Background() + c, err := gaming.NewRealmsClient(ctx) + if err != nil { + // TODO: Handle error. + } + // TODO: Use client. + _ = c +} + +func ExampleRealmsClient_ListRealms() { + // import gamingpb "google.golang.org/genproto/googleapis/cloud/gaming/v1" + // import "google.golang.org/api/iterator" + + ctx := context.Background() + c, err := gaming.NewRealmsClient(ctx) + if err != nil { + // TODO: Handle error. + } + + req := &gamingpb.ListRealmsRequest{ + // TODO: Fill request struct fields. + } + it := c.ListRealms(ctx, req) + for { + resp, err := it.Next() + if err == iterator.Done { + break + } + if err != nil { + // TODO: Handle error. + } + // TODO: Use resp. + _ = resp + } +} + +func ExampleRealmsClient_GetRealm() { + // import gamingpb "google.golang.org/genproto/googleapis/cloud/gaming/v1" + + ctx := context.Background() + c, err := gaming.NewRealmsClient(ctx) + if err != nil { + // TODO: Handle error. + } + + req := &gamingpb.GetRealmRequest{ + // TODO: Fill request struct fields. + } + resp, err := c.GetRealm(ctx, req) + if err != nil { + // TODO: Handle error. + } + // TODO: Use resp. + _ = resp +} + +func ExampleRealmsClient_CreateRealm() { + // import gamingpb "google.golang.org/genproto/googleapis/cloud/gaming/v1" + + ctx := context.Background() + c, err := gaming.NewRealmsClient(ctx) + if err != nil { + // TODO: Handle error. + } + + req := &gamingpb.CreateRealmRequest{ + // TODO: Fill request struct fields. + } + op, err := c.CreateRealm(ctx, req) + if err != nil { + // TODO: Handle error. + } + + resp, err := op.Wait(ctx) + if err != nil { + // TODO: Handle error. + } + // TODO: Use resp. + _ = resp +} + +func ExampleRealmsClient_DeleteRealm() { + // import gamingpb "google.golang.org/genproto/googleapis/cloud/gaming/v1" + + ctx := context.Background() + c, err := gaming.NewRealmsClient(ctx) + if err != nil { + // TODO: Handle error. + } + + req := &gamingpb.DeleteRealmRequest{ + // TODO: Fill request struct fields. + } + op, err := c.DeleteRealm(ctx, req) + if err != nil { + // TODO: Handle error. + } + + err = op.Wait(ctx) + if err != nil { + // TODO: Handle error. + } +} + +func ExampleRealmsClient_UpdateRealm() { + // import gamingpb "google.golang.org/genproto/googleapis/cloud/gaming/v1" + + ctx := context.Background() + c, err := gaming.NewRealmsClient(ctx) + if err != nil { + // TODO: Handle error. + } + + req := &gamingpb.UpdateRealmRequest{ + // TODO: Fill request struct fields. + } + op, err := c.UpdateRealm(ctx, req) + if err != nil { + // TODO: Handle error. + } + + resp, err := op.Wait(ctx) + if err != nil { + // TODO: Handle error. + } + // TODO: Use resp. + _ = resp +} + +func ExampleRealmsClient_PreviewRealmUpdate() { + // import gamingpb "google.golang.org/genproto/googleapis/cloud/gaming/v1" + + ctx := context.Background() + c, err := gaming.NewRealmsClient(ctx) + if err != nil { + // TODO: Handle error. + } + + req := &gamingpb.PreviewRealmUpdateRequest{ + // TODO: Fill request struct fields. + } + resp, err := c.PreviewRealmUpdate(ctx, req) + if err != nil { + // TODO: Handle error. + } + // TODO: Use resp. + _ = resp +} diff --git a/internal/.repo-metadata-full.json b/internal/.repo-metadata-full.json index 136eb591115..d2d7ebae09a 100644 --- a/internal/.repo-metadata-full.json +++ b/internal/.repo-metadata-full.json @@ -327,6 +327,14 @@ "docs_url": "https://pkg.go.dev/cloud.google.com/go/functions/apiv1", "release_level": "beta" }, + "cloud.google.com/go/gaming/apiv1": { + "distribution_name": "cloud.google.com/go/gaming/apiv1", + "description": "", + "language": "Go", + "client_library_type": "generated", + "docs_url": "https://pkg.go.dev/cloud.google.com/go/gaming/apiv1", + "release_level": "beta" + }, "cloud.google.com/go/gaming/apiv1beta": { "distribution_name": "cloud.google.com/go/gaming/apiv1beta", "description": "", diff --git a/internal/gapicgen/generator/config.go b/internal/gapicgen/generator/config.go index 2b3232fd367..d936fa86258 100644 --- a/internal/gapicgen/generator/config.go +++ b/internal/gapicgen/generator/config.go @@ -704,6 +704,14 @@ var microgenGapicConfigs = []*microgenConfig{ apiServiceConfigPath: "google/cloud/servicedirectory/v1beta1/servicedirectory_v1beta1.yaml", releaseLevel: "beta", }, + { + inputDirectoryPath: "google/cloud/gaming/v1", + pkg: "gaming", + importPath: "cloud.google.com/go/gaming/apiv1", + gRPCServiceConfigPath: "google/cloud/gaming/v1/gaming_grpc_service_config.json", + apiServiceConfigPath: "google/cloud/gaming/v1/gaming_gapic.yaml", + releaseLevel: "beta", + }, { inputDirectoryPath: "google/cloud/gaming/v1beta", pkg: "gaming",