public async stt::Task PreviewDeleteGameServerClusterRequestObjectAsync() { moq::Mock <GameServerClustersService.GameServerClustersServiceClient> mockGrpcClient = new moq::Mock <GameServerClustersService.GameServerClustersServiceClient>(moq::MockBehavior.Strict); mockGrpcClient.Setup(x => x.CreateOperationsClient()).Returns(new moq::Mock <lro::Operations.OperationsClient>().Object); PreviewDeleteGameServerClusterRequest request = new PreviewDeleteGameServerClusterRequest { GameServerClusterName = GameServerClusterName.FromProjectLocationRealmCluster("[PROJECT]", "[LOCATION]", "[REALM]", "[CLUSTER]"), PreviewTime = new wkt::Timestamp(), }; PreviewDeleteGameServerClusterResponse expectedResponse = new PreviewDeleteGameServerClusterResponse { Etag = "etage8ad7218", TargetState = new TargetState(), }; mockGrpcClient.Setup(x => x.PreviewDeleteGameServerClusterAsync(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(new grpccore::AsyncUnaryCall <PreviewDeleteGameServerClusterResponse>(stt::Task.FromResult(expectedResponse), null, null, null, null)); GameServerClustersServiceClient client = new GameServerClustersServiceClientImpl(mockGrpcClient.Object, null); PreviewDeleteGameServerClusterResponse responseCallSettings = await client.PreviewDeleteGameServerClusterAsync(request, gaxgrpc::CallSettings.FromCancellationToken(st::CancellationToken.None)); xunit::Assert.Same(expectedResponse, responseCallSettings); PreviewDeleteGameServerClusterResponse responseCancellationToken = await client.PreviewDeleteGameServerClusterAsync(request, st::CancellationToken.None); xunit::Assert.Same(expectedResponse, responseCancellationToken); mockGrpcClient.VerifyAll(); }
public async Task <GameServerCluster> UpdateClusterAsync( string projectId, string regionId, string realmId, string clusterId) { // Create the client. GameServerClustersServiceClient client = await GameServerClustersServiceClient.CreateAsync(); GameServerCluster cluster = new GameServerCluster() { GameServerClusterName = GameServerClusterName.FromProjectLocationRealmCluster(projectId, regionId, realmId, clusterId) }; cluster.Labels.Add("label-key-1", "label-value-1"); cluster.Labels.Add("label-key-2", "label-value-2"); UpdateGameServerClusterRequest request = new UpdateGameServerClusterRequest { GameServerCluster = cluster, UpdateMask = new FieldMask { Paths = { "labels" } } }; // Make the request. Operation <GameServerCluster, OperationMetadata> response = await client.UpdateGameServerClusterAsync(request); Operation <GameServerCluster, OperationMetadata> completedResponse = await response.PollUntilCompletedAsync(); // Retrieve the operation result. This result will NOT contain the updated labels. // If you want to get the updated resource, use a GET request on the resource. return(completedResponse.Result); }
public void GetGameServerClusterRequestObject() { moq::Mock <GameServerClustersService.GameServerClustersServiceClient> mockGrpcClient = new moq::Mock <GameServerClustersService.GameServerClustersServiceClient>(moq::MockBehavior.Strict); mockGrpcClient.Setup(x => x.CreateOperationsClient()).Returns(new moq::Mock <lro::Operations.OperationsClient>().Object); GetGameServerClusterRequest request = new GetGameServerClusterRequest { GameServerClusterName = GameServerClusterName.FromProjectLocationRealmCluster("[PROJECT]", "[LOCATION]", "[REALM]", "[CLUSTER]"), }; GameServerCluster expectedResponse = new GameServerCluster { GameServerClusterName = GameServerClusterName.FromProjectLocationRealmCluster("[PROJECT]", "[LOCATION]", "[REALM]", "[CLUSTER]"), CreateTime = new wkt::Timestamp(), UpdateTime = new wkt::Timestamp(), Labels = { { "key8a0b6e3c", "value60c16320" }, }, ConnectionInfo = new GameServerClusterConnectionInfo(), Etag = "etage8ad7218", Description = "description2cf9da67", }; mockGrpcClient.Setup(x => x.GetGameServerCluster(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(expectedResponse); GameServerClustersServiceClient client = new GameServerClustersServiceClientImpl(mockGrpcClient.Object, null); GameServerCluster response = client.GetGameServerCluster(request); xunit::Assert.Same(expectedResponse, response); mockGrpcClient.VerifyAll(); }
public async Task <GameServerCluster> CreateClusterAsync( string projectId, string regionId, string realmId, string clusterId, string gkeName) { // Create the client. GameServerClustersServiceClient client = await GameServerClustersServiceClient.CreateAsync(); GameServerCluster cluster = new GameServerCluster() { GameServerClusterName = GameServerClusterName.FromProjectLocationRealmCluster(projectId, regionId, realmId, clusterId), ConnectionInfo = new GameServerClusterConnectionInfo { GkeClusterReference = new GkeClusterReference { Cluster = gkeName }, Namespace = "default" } }; CreateGameServerClusterRequest request = new CreateGameServerClusterRequest { ParentAsRealmName = RealmName.FromProjectLocationRealm(projectId, regionId, realmId), GameServerClusterId = clusterId, GameServerCluster = cluster }; // Make the request. Operation <GameServerCluster, OperationMetadata> response = await client.CreateGameServerClusterAsync(request); // Poll until the returned long-running operation is complete. Operation <GameServerCluster, OperationMetadata> completedResponse = await response.PollUntilCompletedAsync(); // Retrieve the operation result. return(completedResponse.Result); }
public void DeleteCluster( string projectId, string regionId, string realmId, string clusterId) { // Create the client. GameServerClustersServiceClient client = GameServerClustersServiceClient.Create(); DeleteGameServerClusterRequest request = new DeleteGameServerClusterRequest { GameServerClusterName = GameServerClusterName.FromProjectLocationRealmCluster(projectId, regionId, realmId, clusterId) }; // Make the request. Operation <Empty, OperationMetadata> response = client.DeleteGameServerCluster(request); // Poll until the returned long-running operation is complete. response.PollUntilCompleted(); }
public GameServerCluster GetCluster( string projectId, string regionId, string realmId, string clusterId) { // Create the client. GameServerClustersServiceClient client = GameServerClustersServiceClient.Create(); GetGameServerClusterRequest request = new GetGameServerClusterRequest { GameServerClusterName = GameServerClusterName.FromProjectLocationRealmCluster(projectId, regionId, realmId, clusterId), View = GameServerClusterView.Full }; // Make the request. GameServerCluster response = client.GetGameServerCluster(request); // You could write response.Name and response.ClusterState to the console // to see the installed versions of Agones and Kubernetes on the cluster. return(response); }
public async stt::Task GetGameServerClusterRequestObjectAsync() { moq::Mock <GameServerClustersService.GameServerClustersServiceClient> mockGrpcClient = new moq::Mock <GameServerClustersService.GameServerClustersServiceClient>(moq::MockBehavior.Strict); mockGrpcClient.Setup(x => x.CreateOperationsClient()).Returns(new moq::Mock <lro::Operations.OperationsClient>().Object); GetGameServerClusterRequest request = new GetGameServerClusterRequest { GameServerClusterName = GameServerClusterName.FromProjectLocationRealmCluster("[PROJECT]", "[LOCATION]", "[REALM]", "[CLUSTER]"), View = GameServerClusterView.Basic, }; GameServerCluster expectedResponse = new GameServerCluster { GameServerClusterName = GameServerClusterName.FromProjectLocationRealmCluster("[PROJECT]", "[LOCATION]", "[REALM]", "[CLUSTER]"), CreateTime = new wkt::Timestamp(), UpdateTime = new wkt::Timestamp(), Labels = { { "key8a0b6e3c", "value60c16320" }, }, ConnectionInfo = new GameServerClusterConnectionInfo(), Etag = "etage8ad7218", Description = "description2cf9da67", ClusterState = new KubernetesClusterState(), }; mockGrpcClient.Setup(x => x.GetGameServerClusterAsync(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(new grpccore::AsyncUnaryCall <GameServerCluster>(stt::Task.FromResult(expectedResponse), null, null, null, null)); GameServerClustersServiceClient client = new GameServerClustersServiceClientImpl(mockGrpcClient.Object, null); GameServerCluster responseCallSettings = await client.GetGameServerClusterAsync(request, gaxgrpc::CallSettings.FromCancellationToken(st::CancellationToken.None)); xunit::Assert.Same(expectedResponse, responseCallSettings); GameServerCluster responseCancellationToken = await client.GetGameServerClusterAsync(request, st::CancellationToken.None); xunit::Assert.Same(expectedResponse, responseCancellationToken); mockGrpcClient.VerifyAll(); }
public void PreviewDeleteGameServerClusterRequestObject() { moq::Mock <GameServerClustersService.GameServerClustersServiceClient> mockGrpcClient = new moq::Mock <GameServerClustersService.GameServerClustersServiceClient>(moq::MockBehavior.Strict); mockGrpcClient.Setup(x => x.CreateOperationsClient()).Returns(new moq::Mock <lro::Operations.OperationsClient>().Object); PreviewDeleteGameServerClusterRequest request = new PreviewDeleteGameServerClusterRequest { GameServerClusterName = GameServerClusterName.FromProjectLocationRealmCluster("[PROJECT]", "[LOCATION]", "[REALM]", "[CLUSTER]"), PreviewTime = new wkt::Timestamp(), }; PreviewDeleteGameServerClusterResponse expectedResponse = new PreviewDeleteGameServerClusterResponse { Etag = "etage8ad7218", TargetState = new TargetState(), }; mockGrpcClient.Setup(x => x.PreviewDeleteGameServerCluster(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(expectedResponse); GameServerClustersServiceClient client = new GameServerClustersServiceClientImpl(mockGrpcClient.Object, null); PreviewDeleteGameServerClusterResponse response = client.PreviewDeleteGameServerCluster(request); xunit::Assert.Same(expectedResponse, response); mockGrpcClient.VerifyAll(); }