@Generated(value="by gapic-generator") @BetaApi public class GameServerClustersServiceClient extends Object implements BackgroundResource
This class provides the ability to make remote calls to the backing service through method calls that map to API methods. Sample code to get started:
try (GameServerClustersServiceClient gameServerClustersServiceClient = GameServerClustersServiceClient.create()) {
String formattedName = GameServerClustersServiceClient.formatGameServerClusterName("[PROJECT]", "[LOCATION]", "[REALM]", "[GAME_SERVER_CLUSTER]");
GameServerCluster response = gameServerClustersServiceClient.getGameServerCluster(formattedName);
}
Note: close() needs to be called on the gameServerClustersServiceClient object to clean up resources such as threads. In the example above, try-with-resources is used, which automatically calls close().
The surface of this class includes several types of Java methods for each of the API's methods:
See the individual methods for example code.
Many parameters require resource names to be formatted in a particular way. To assist with these names, this class includes a format method for each type of name, and additionally a parse method to extract the individual identifiers contained within names that are returned.
This class can be customized by passing in a custom instance of GameServerClustersServiceSettings to create(). For example:
To customize credentials:
GameServerClustersServiceSettings gameServerClustersServiceSettings =
GameServerClustersServiceSettings.newBuilder()
.setCredentialsProvider(FixedCredentialsProvider.create(myCredentials))
.build();
GameServerClustersServiceClient gameServerClustersServiceClient =
GameServerClustersServiceClient.create(gameServerClustersServiceSettings);
To customize the endpoint:
GameServerClustersServiceSettings gameServerClustersServiceSettings =
GameServerClustersServiceSettings.newBuilder().setEndpoint(myEndpoint).build();
GameServerClustersServiceClient gameServerClustersServiceClient =
GameServerClustersServiceClient.create(gameServerClustersServiceSettings);
Modifier and Type | Class and Description |
---|---|
static class |
GameServerClustersServiceClient.ListGameServerClustersFixedSizeCollection |
static class |
GameServerClustersServiceClient.ListGameServerClustersPage |
static class |
GameServerClustersServiceClient.ListGameServerClustersPagedResponse |
Modifier | Constructor and Description |
---|---|
protected |
GameServerClustersServiceClient(GameServerClustersServiceSettings settings)
Constructs an instance of GameServerClustersServiceClient, using the given settings.
|
protected |
GameServerClustersServiceClient(GameServerClustersServiceStub stub) |
protected GameServerClustersServiceClient(GameServerClustersServiceSettings settings) throws IOException
IOException
@BetaApi(value="A restructuring of stub classes is planned, so this may break in the future") protected GameServerClustersServiceClient(GameServerClustersServiceStub stub)
@Deprecated public static final String formatGameServerClusterName(String project, String location, String realm, String gameServerCluster)
GameServerClusterName
class instead.@Deprecated public static final String formatRealmName(String project, String location, String realm)
RealmName
class instead.@Deprecated public static final String parseProjectFromGameServerClusterName(String gameServerClusterName)
GameServerClusterName
class instead.@Deprecated public static final String parseLocationFromGameServerClusterName(String gameServerClusterName)
GameServerClusterName
class instead.@Deprecated public static final String parseRealmFromGameServerClusterName(String gameServerClusterName)
GameServerClusterName
class instead.@Deprecated public static final String parseGameServerClusterFromGameServerClusterName(String gameServerClusterName)
GameServerClusterName
class instead.@Deprecated public static final String parseProjectFromRealmName(String realmName)
RealmName
class instead.@Deprecated public static final String parseLocationFromRealmName(String realmName)
RealmName
class instead.@Deprecated public static final String parseRealmFromRealmName(String realmName)
RealmName
class instead.public static final GameServerClustersServiceClient create() throws IOException
IOException
public static final GameServerClustersServiceClient create(GameServerClustersServiceSettings settings) throws IOException
IOException
@BetaApi(value="A restructuring of stub classes is planned, so this may break in the future") public static final GameServerClustersServiceClient create(GameServerClustersServiceStub stub)
public final GameServerClustersServiceSettings getSettings()
@BetaApi(value="A restructuring of stub classes is planned, so this may break in the future") public GameServerClustersServiceStub getStub()
@BetaApi(value="The surface for long-running operations is not stable yet and may change in the future.") public final OperationsClient getOperationsClient()
public final GameServerClustersServiceClient.ListGameServerClustersPagedResponse listGameServerClusters(String parent)
Sample code:
try (GameServerClustersServiceClient gameServerClustersServiceClient = GameServerClustersServiceClient.create()) {
String formattedParent = GameServerClustersServiceClient.formatRealmName("[PROJECT]", "[LOCATION]", "[REALM]");
for (GameServerCluster element : gameServerClustersServiceClient.listGameServerClusters(formattedParent).iterateAll()) {
// doThingsWith(element);
}
}
parent
- Required. The parent resource name, using the form:
"projects/{project}/locations/{location}/realms/{realm-id}".ApiException
- if the remote call failspublic final GameServerClustersServiceClient.ListGameServerClustersPagedResponse listGameServerClusters(ListGameServerClustersRequest request)
Sample code:
try (GameServerClustersServiceClient gameServerClustersServiceClient = GameServerClustersServiceClient.create()) {
String formattedParent = GameServerClustersServiceClient.formatRealmName("[PROJECT]", "[LOCATION]", "[REALM]");
ListGameServerClustersRequest request = ListGameServerClustersRequest.newBuilder()
.setParent(formattedParent)
.build();
for (GameServerCluster element : gameServerClustersServiceClient.listGameServerClusters(request).iterateAll()) {
// doThingsWith(element);
}
}
request
- The request object containing all of the parameters for the API call.ApiException
- if the remote call failspublic final UnaryCallable<ListGameServerClustersRequest,GameServerClustersServiceClient.ListGameServerClustersPagedResponse> listGameServerClustersPagedCallable()
Sample code:
try (GameServerClustersServiceClient gameServerClustersServiceClient = GameServerClustersServiceClient.create()) {
String formattedParent = GameServerClustersServiceClient.formatRealmName("[PROJECT]", "[LOCATION]", "[REALM]");
ListGameServerClustersRequest request = ListGameServerClustersRequest.newBuilder()
.setParent(formattedParent)
.build();
ApiFuture<ListGameServerClustersPagedResponse> future = gameServerClustersServiceClient.listGameServerClustersPagedCallable().futureCall(request);
// Do something
for (GameServerCluster element : future.get().iterateAll()) {
// doThingsWith(element);
}
}
public final UnaryCallable<ListGameServerClustersRequest,ListGameServerClustersResponse> listGameServerClustersCallable()
Sample code:
try (GameServerClustersServiceClient gameServerClustersServiceClient = GameServerClustersServiceClient.create()) {
String formattedParent = GameServerClustersServiceClient.formatRealmName("[PROJECT]", "[LOCATION]", "[REALM]");
ListGameServerClustersRequest request = ListGameServerClustersRequest.newBuilder()
.setParent(formattedParent)
.build();
while (true) {
ListGameServerClustersResponse response = gameServerClustersServiceClient.listGameServerClustersCallable().call(request);
for (GameServerCluster element : response.getGameServerClustersList()) {
// doThingsWith(element);
}
String nextPageToken = response.getNextPageToken();
if (!Strings.isNullOrEmpty(nextPageToken)) {
request = request.toBuilder().setPageToken(nextPageToken).build();
} else {
break;
}
}
}
public final GameServerCluster getGameServerCluster(String name)
Sample code:
try (GameServerClustersServiceClient gameServerClustersServiceClient = GameServerClustersServiceClient.create()) {
String formattedName = GameServerClustersServiceClient.formatGameServerClusterName("[PROJECT]", "[LOCATION]", "[REALM]", "[GAME_SERVER_CLUSTER]");
GameServerCluster response = gameServerClustersServiceClient.getGameServerCluster(formattedName);
}
name
- Required. The name of the game server cluster to retrieve, using the form:
`projects/{project}/locations/{location}/realms/{realm-id}/gameServerClusters/{cluster}`
ApiException
- if the remote call failspublic final GameServerCluster getGameServerCluster(GetGameServerClusterRequest request)
Sample code:
try (GameServerClustersServiceClient gameServerClustersServiceClient = GameServerClustersServiceClient.create()) {
String formattedName = GameServerClustersServiceClient.formatGameServerClusterName("[PROJECT]", "[LOCATION]", "[REALM]", "[GAME_SERVER_CLUSTER]");
GetGameServerClusterRequest request = GetGameServerClusterRequest.newBuilder()
.setName(formattedName)
.build();
GameServerCluster response = gameServerClustersServiceClient.getGameServerCluster(request);
}
request
- The request object containing all of the parameters for the API call.ApiException
- if the remote call failspublic final UnaryCallable<GetGameServerClusterRequest,GameServerCluster> getGameServerClusterCallable()
Sample code:
try (GameServerClustersServiceClient gameServerClustersServiceClient = GameServerClustersServiceClient.create()) {
String formattedName = GameServerClustersServiceClient.formatGameServerClusterName("[PROJECT]", "[LOCATION]", "[REALM]", "[GAME_SERVER_CLUSTER]");
GetGameServerClusterRequest request = GetGameServerClusterRequest.newBuilder()
.setName(formattedName)
.build();
ApiFuture<GameServerCluster> future = gameServerClustersServiceClient.getGameServerClusterCallable().futureCall(request);
// Do something
GameServerCluster response = future.get();
}
@BetaApi(value="The surface for long-running operations is not stable yet and may change in the future.") public final OperationFuture<GameServerCluster,Empty> createGameServerClusterAsync(String parent, String gameServerClusterId, GameServerCluster gameServerCluster)
Sample code:
try (GameServerClustersServiceClient gameServerClustersServiceClient = GameServerClustersServiceClient.create()) {
String formattedParent = GameServerClustersServiceClient.formatRealmName("[PROJECT]", "[LOCATION]", "[REALM]");
String gameServerClusterId = "";
GameServerCluster gameServerCluster = GameServerCluster.newBuilder().build();
GameServerCluster response = gameServerClustersServiceClient.createGameServerClusterAsync(formattedParent, gameServerClusterId, gameServerCluster).get();
}
parent
- Required. The parent resource name, using the form:
`projects/{project}/locations/{location}/realms/{realm-id}`.gameServerClusterId
- Required. The ID of the game server cluster resource to be created.gameServerCluster
- Required. The game server cluster resource to be created.ApiException
- if the remote call fails@BetaApi(value="The surface for long-running operations is not stable yet and may change in the future.") public final OperationFuture<GameServerCluster,Empty> createGameServerClusterAsync(CreateGameServerClusterRequest request)
Sample code:
try (GameServerClustersServiceClient gameServerClustersServiceClient = GameServerClustersServiceClient.create()) {
String formattedParent = GameServerClustersServiceClient.formatRealmName("[PROJECT]", "[LOCATION]", "[REALM]");
String gameServerClusterId = "";
GameServerCluster gameServerCluster = GameServerCluster.newBuilder().build();
CreateGameServerClusterRequest request = CreateGameServerClusterRequest.newBuilder()
.setParent(formattedParent)
.setGameServerClusterId(gameServerClusterId)
.setGameServerCluster(gameServerCluster)
.build();
GameServerCluster response = gameServerClustersServiceClient.createGameServerClusterAsync(request).get();
}
request
- The request object containing all of the parameters for the API call.ApiException
- if the remote call fails@BetaApi(value="The surface for use by generated code is not stable yet and may change in the future.") public final OperationCallable<CreateGameServerClusterRequest,GameServerCluster,Empty> createGameServerClusterOperationCallable()
Sample code:
try (GameServerClustersServiceClient gameServerClustersServiceClient = GameServerClustersServiceClient.create()) {
String formattedParent = GameServerClustersServiceClient.formatRealmName("[PROJECT]", "[LOCATION]", "[REALM]");
String gameServerClusterId = "";
GameServerCluster gameServerCluster = GameServerCluster.newBuilder().build();
CreateGameServerClusterRequest request = CreateGameServerClusterRequest.newBuilder()
.setParent(formattedParent)
.setGameServerClusterId(gameServerClusterId)
.setGameServerCluster(gameServerCluster)
.build();
OperationFuture<GameServerCluster, Empty> future = gameServerClustersServiceClient.createGameServerClusterOperationCallable().futureCall(request);
// Do something
GameServerCluster response = future.get();
}
public final UnaryCallable<CreateGameServerClusterRequest,Operation> createGameServerClusterCallable()
Sample code:
try (GameServerClustersServiceClient gameServerClustersServiceClient = GameServerClustersServiceClient.create()) {
String formattedParent = GameServerClustersServiceClient.formatRealmName("[PROJECT]", "[LOCATION]", "[REALM]");
String gameServerClusterId = "";
GameServerCluster gameServerCluster = GameServerCluster.newBuilder().build();
CreateGameServerClusterRequest request = CreateGameServerClusterRequest.newBuilder()
.setParent(formattedParent)
.setGameServerClusterId(gameServerClusterId)
.setGameServerCluster(gameServerCluster)
.build();
ApiFuture<Operation> future = gameServerClustersServiceClient.createGameServerClusterCallable().futureCall(request);
// Do something
Operation response = future.get();
}
@BetaApi(value="The surface for long-running operations is not stable yet and may change in the future.") public final OperationFuture<Empty,Empty> deleteGameServerClusterAsync(String name)
Sample code:
try (GameServerClustersServiceClient gameServerClustersServiceClient = GameServerClustersServiceClient.create()) {
String formattedName = GameServerClustersServiceClient.formatGameServerClusterName("[PROJECT]", "[LOCATION]", "[REALM]", "[GAME_SERVER_CLUSTER]");
gameServerClustersServiceClient.deleteGameServerClusterAsync(formattedName).get();
}
name
- Required. The name of the game server cluster to delete, using the form:
`projects/{project}/locations/{location}/gameServerClusters/{cluster}`ApiException
- if the remote call fails@BetaApi(value="The surface for long-running operations is not stable yet and may change in the future.") public final OperationFuture<Empty,Empty> deleteGameServerClusterAsync(DeleteGameServerClusterRequest request)
Sample code:
try (GameServerClustersServiceClient gameServerClustersServiceClient = GameServerClustersServiceClient.create()) {
String formattedName = GameServerClustersServiceClient.formatGameServerClusterName("[PROJECT]", "[LOCATION]", "[REALM]", "[GAME_SERVER_CLUSTER]");
DeleteGameServerClusterRequest request = DeleteGameServerClusterRequest.newBuilder()
.setName(formattedName)
.build();
gameServerClustersServiceClient.deleteGameServerClusterAsync(request).get();
}
request
- The request object containing all of the parameters for the API call.ApiException
- if the remote call fails@BetaApi(value="The surface for use by generated code is not stable yet and may change in the future.") public final OperationCallable<DeleteGameServerClusterRequest,Empty,Empty> deleteGameServerClusterOperationCallable()
Sample code:
try (GameServerClustersServiceClient gameServerClustersServiceClient = GameServerClustersServiceClient.create()) {
String formattedName = GameServerClustersServiceClient.formatGameServerClusterName("[PROJECT]", "[LOCATION]", "[REALM]", "[GAME_SERVER_CLUSTER]");
DeleteGameServerClusterRequest request = DeleteGameServerClusterRequest.newBuilder()
.setName(formattedName)
.build();
OperationFuture<Empty, Empty> future = gameServerClustersServiceClient.deleteGameServerClusterOperationCallable().futureCall(request);
// Do something
future.get();
}
public final UnaryCallable<DeleteGameServerClusterRequest,Operation> deleteGameServerClusterCallable()
Sample code:
try (GameServerClustersServiceClient gameServerClustersServiceClient = GameServerClustersServiceClient.create()) {
String formattedName = GameServerClustersServiceClient.formatGameServerClusterName("[PROJECT]", "[LOCATION]", "[REALM]", "[GAME_SERVER_CLUSTER]");
DeleteGameServerClusterRequest request = DeleteGameServerClusterRequest.newBuilder()
.setName(formattedName)
.build();
ApiFuture<Operation> future = gameServerClustersServiceClient.deleteGameServerClusterCallable().futureCall(request);
// Do something
future.get();
}
@BetaApi(value="The surface for long-running operations is not stable yet and may change in the future.") public final OperationFuture<GameServerCluster,Empty> updateGameServerClusterAsync(GameServerCluster gameServerCluster, FieldMask updateMask)
Sample code:
try (GameServerClustersServiceClient gameServerClustersServiceClient = GameServerClustersServiceClient.create()) {
GameServerCluster gameServerCluster = GameServerCluster.newBuilder().build();
FieldMask updateMask = FieldMask.newBuilder().build();
GameServerCluster response = gameServerClustersServiceClient.updateGameServerClusterAsync(gameServerCluster, updateMask).get();
}
gameServerCluster
- Required. The game server cluster to be updated. Only fields specified
in update_mask are updated.updateMask
- Required. Mask of fields to update. At least one path must be supplied in
this field. For the `FieldMask` definition, see
https: //developers.google.com/protocol-buffers // /docs/reference/google.protobuf#fieldmask
ApiException
- if the remote call fails@BetaApi(value="The surface for long-running operations is not stable yet and may change in the future.") public final OperationFuture<GameServerCluster,Empty> updateGameServerClusterAsync(UpdateGameServerClusterRequest request)
Sample code:
try (GameServerClustersServiceClient gameServerClustersServiceClient = GameServerClustersServiceClient.create()) {
GameServerCluster gameServerCluster = GameServerCluster.newBuilder().build();
FieldMask updateMask = FieldMask.newBuilder().build();
UpdateGameServerClusterRequest request = UpdateGameServerClusterRequest.newBuilder()
.setGameServerCluster(gameServerCluster)
.setUpdateMask(updateMask)
.build();
GameServerCluster response = gameServerClustersServiceClient.updateGameServerClusterAsync(request).get();
}
request
- The request object containing all of the parameters for the API call.ApiException
- if the remote call fails@BetaApi(value="The surface for use by generated code is not stable yet and may change in the future.") public final OperationCallable<UpdateGameServerClusterRequest,GameServerCluster,Empty> updateGameServerClusterOperationCallable()
Sample code:
try (GameServerClustersServiceClient gameServerClustersServiceClient = GameServerClustersServiceClient.create()) {
GameServerCluster gameServerCluster = GameServerCluster.newBuilder().build();
FieldMask updateMask = FieldMask.newBuilder().build();
UpdateGameServerClusterRequest request = UpdateGameServerClusterRequest.newBuilder()
.setGameServerCluster(gameServerCluster)
.setUpdateMask(updateMask)
.build();
OperationFuture<GameServerCluster, Empty> future = gameServerClustersServiceClient.updateGameServerClusterOperationCallable().futureCall(request);
// Do something
GameServerCluster response = future.get();
}
public final UnaryCallable<UpdateGameServerClusterRequest,Operation> updateGameServerClusterCallable()
Sample code:
try (GameServerClustersServiceClient gameServerClustersServiceClient = GameServerClustersServiceClient.create()) {
GameServerCluster gameServerCluster = GameServerCluster.newBuilder().build();
FieldMask updateMask = FieldMask.newBuilder().build();
UpdateGameServerClusterRequest request = UpdateGameServerClusterRequest.newBuilder()
.setGameServerCluster(gameServerCluster)
.setUpdateMask(updateMask)
.build();
ApiFuture<Operation> future = gameServerClustersServiceClient.updateGameServerClusterCallable().futureCall(request);
// Do something
Operation response = future.get();
}
public final PreviewCreateGameServerClusterResponse previewCreateGameServerCluster(PreviewCreateGameServerClusterRequest request)
Sample code:
try (GameServerClustersServiceClient gameServerClustersServiceClient = GameServerClustersServiceClient.create()) {
PreviewCreateGameServerClusterRequest request = PreviewCreateGameServerClusterRequest.newBuilder().build();
PreviewCreateGameServerClusterResponse response = gameServerClustersServiceClient.previewCreateGameServerCluster(request);
}
request
- The request object containing all of the parameters for the API call.ApiException
- if the remote call failspublic final UnaryCallable<PreviewCreateGameServerClusterRequest,PreviewCreateGameServerClusterResponse> previewCreateGameServerClusterCallable()
Sample code:
try (GameServerClustersServiceClient gameServerClustersServiceClient = GameServerClustersServiceClient.create()) {
PreviewCreateGameServerClusterRequest request = PreviewCreateGameServerClusterRequest.newBuilder().build();
ApiFuture<PreviewCreateGameServerClusterResponse> future = gameServerClustersServiceClient.previewCreateGameServerClusterCallable().futureCall(request);
// Do something
PreviewCreateGameServerClusterResponse response = future.get();
}
public final PreviewDeleteGameServerClusterResponse previewDeleteGameServerCluster(PreviewDeleteGameServerClusterRequest request)
Sample code:
try (GameServerClustersServiceClient gameServerClustersServiceClient = GameServerClustersServiceClient.create()) {
PreviewDeleteGameServerClusterRequest request = PreviewDeleteGameServerClusterRequest.newBuilder().build();
PreviewDeleteGameServerClusterResponse response = gameServerClustersServiceClient.previewDeleteGameServerCluster(request);
}
request
- The request object containing all of the parameters for the API call.ApiException
- if the remote call failspublic final UnaryCallable<PreviewDeleteGameServerClusterRequest,PreviewDeleteGameServerClusterResponse> previewDeleteGameServerClusterCallable()
Sample code:
try (GameServerClustersServiceClient gameServerClustersServiceClient = GameServerClustersServiceClient.create()) {
PreviewDeleteGameServerClusterRequest request = PreviewDeleteGameServerClusterRequest.newBuilder().build();
ApiFuture<PreviewDeleteGameServerClusterResponse> future = gameServerClustersServiceClient.previewDeleteGameServerClusterCallable().futureCall(request);
// Do something
PreviewDeleteGameServerClusterResponse response = future.get();
}
public final PreviewUpdateGameServerClusterResponse previewUpdateGameServerCluster(PreviewUpdateGameServerClusterRequest request)
Sample code:
try (GameServerClustersServiceClient gameServerClustersServiceClient = GameServerClustersServiceClient.create()) {
PreviewUpdateGameServerClusterRequest request = PreviewUpdateGameServerClusterRequest.newBuilder().build();
PreviewUpdateGameServerClusterResponse response = gameServerClustersServiceClient.previewUpdateGameServerCluster(request);
}
request
- The request object containing all of the parameters for the API call.ApiException
- if the remote call failspublic final UnaryCallable<PreviewUpdateGameServerClusterRequest,PreviewUpdateGameServerClusterResponse> previewUpdateGameServerClusterCallable()
Sample code:
try (GameServerClustersServiceClient gameServerClustersServiceClient = GameServerClustersServiceClient.create()) {
PreviewUpdateGameServerClusterRequest request = PreviewUpdateGameServerClusterRequest.newBuilder().build();
ApiFuture<PreviewUpdateGameServerClusterResponse> future = gameServerClustersServiceClient.previewUpdateGameServerClusterCallable().futureCall(request);
// Do something
PreviewUpdateGameServerClusterResponse response = future.get();
}
public final void close()
close
in interface AutoCloseable
public void shutdown()
shutdown
in interface BackgroundResource
public boolean isShutdown()
isShutdown
in interface BackgroundResource
public boolean isTerminated()
isTerminated
in interface BackgroundResource
public void shutdownNow()
shutdownNow
in interface BackgroundResource
public boolean awaitTermination(long duration, TimeUnit unit) throws InterruptedException
awaitTermination
in interface BackgroundResource
InterruptedException
Copyright © 2020 Google LLC. All rights reserved.