// 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
//
//     http://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.

syntax = "proto3";

package google.cloud.gaming.v1;

import "google/api/annotations.proto";
import "google/api/client.proto";
import "google/cloud/gaming/v1/game_server_deployments.proto";
import "google/longrunning/operations.proto";

option go_package = "google.golang.org/genproto/googleapis/cloud/gaming/v1;gaming";
option java_multiple_files = true;
option java_package = "com.google.cloud.gaming.v1";

// The game server deployment is used to control the deployment of Agones
// fleets.
service GameServerDeploymentsService {
  option (google.api.default_host) = "gameservices.googleapis.com";
  option (google.api.oauth_scopes) = "https://www.googleapis.com/auth/cloud-platform";

  // Lists game server deployments in a given project and location.
  rpc ListGameServerDeployments(ListGameServerDeploymentsRequest) returns (ListGameServerDeploymentsResponse) {
    option (google.api.http) = {
      get: "/v1/{parent=projects/*/locations/*}/gameServerDeployments"
    };
    option (google.api.method_signature) = "parent";
  }

  // Gets details of a single game server deployment.
  rpc GetGameServerDeployment(GetGameServerDeploymentRequest) returns (GameServerDeployment) {
    option (google.api.http) = {
      get: "/v1/{name=projects/*/locations/*/gameServerDeployments/*}"
    };
    option (google.api.method_signature) = "name";
  }

  // Creates a new game server deployment in a given project and location.
  rpc CreateGameServerDeployment(CreateGameServerDeploymentRequest) returns (google.longrunning.Operation) {
    option (google.api.http) = {
      post: "/v1/{parent=projects/*/locations/*}/gameServerDeployments"
      body: "game_server_deployment"
    };
    option (google.api.method_signature) = "parent,game_server_deployment";
    option (google.longrunning.operation_info) = {
      response_type: "GameServerDeployment"
      metadata_type: "OperationMetadata"
    };
  }

  // Deletes a single game server deployment.
  rpc DeleteGameServerDeployment(DeleteGameServerDeploymentRequest) returns (google.longrunning.Operation) {
    option (google.api.http) = {
      delete: "/v1/{name=projects/*/locations/*/gameServerDeployments/*}"
    };
    option (google.api.method_signature) = "name";
    option (google.longrunning.operation_info) = {
      response_type: "google.protobuf.Empty"
      metadata_type: "OperationMetadata"
    };
  }

  // Patches a game server deployment.
  rpc UpdateGameServerDeployment(UpdateGameServerDeploymentRequest) returns (google.longrunning.Operation) {
    option (google.api.http) = {
      patch: "/v1/{game_server_deployment.name=projects/*/locations/*/gameServerDeployments/*}"
      body: "game_server_deployment"
    };
    option (google.api.method_signature) = "game_server_deployment,update_mask";
    option (google.longrunning.operation_info) = {
      response_type: "GameServerDeployment"
      metadata_type: "OperationMetadata"
    };
  }

  // Gets details a single game server deployment rollout.
  rpc GetGameServerDeploymentRollout(GetGameServerDeploymentRolloutRequest) returns (GameServerDeploymentRollout) {
    option (google.api.http) = {
      get: "/v1/{name=projects/*/locations/*/gameServerDeployments/*}/rollout"
    };
    option (google.api.method_signature) = "name";
  }

  // 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.
  rpc UpdateGameServerDeploymentRollout(UpdateGameServerDeploymentRolloutRequest) returns (google.longrunning.Operation) {
    option (google.api.http) = {
      patch: "/v1/{rollout.name=projects/*/locations/*/gameServerDeployments/*}/rollout"
      body: "rollout"
    };
    option (google.api.method_signature) = "rollout,update_mask";
    option (google.longrunning.operation_info) = {
      response_type: "GameServerDeployment"
      metadata_type: "OperationMetadata"
    };
  }

  // Previews the game server deployment rollout. This API does not mutate the
  // rollout resource.
  rpc PreviewGameServerDeploymentRollout(PreviewGameServerDeploymentRolloutRequest) returns (PreviewGameServerDeploymentRolloutResponse) {
    option (google.api.http) = {
      patch: "/v1/{rollout.name=projects/*/locations/*/gameServerDeployments/*}/rollout:preview"
      body: "rollout"
    };
  }

  // 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.
  rpc FetchDeploymentState(FetchDeploymentStateRequest) returns (FetchDeploymentStateResponse) {
    option (google.api.http) = {
      post: "/v1/{name=projects/*/locations/*/gameServerDeployments/*}:fetchDeploymentState"
      body: "*"
    };
  }
}
