// 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/field_behavior.proto";
import "google/api/resource.proto";
import "google/cloud/gaming/v1/common.proto";
import "google/protobuf/field_mask.proto";
import "google/protobuf/timestamp.proto";
import "google/api/annotations.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";

// Request message for GameServerClustersService.ListGameServerClusters.
message ListGameServerClustersRequest {
  // Required. The parent resource name. Uses the form:
  // "projects/{project}/locations/{location}/realms/{realm}".
  string parent = 1 [
    (google.api.field_behavior) = REQUIRED,
    (google.api.resource_reference) = {
      child_type: "gameservices.googleapis.com/GameServerCluster"
    }
  ];

  // Optional. The maximum number of items to return.  If unspecified, the server
  // will pick an appropriate default. The server may return fewer items than
  // requested. A caller should only rely on response's
  // [next_page_token][google.cloud.gaming.v1.ListGameServerClustersResponse.next_page_token] to
  // determine if there are more GameServerClusters left to be queried.
  int32 page_size = 2 [(google.api.field_behavior) = OPTIONAL];

  // Optional. The next_page_token value returned from a previous List request, if any.
  string page_token = 3 [(google.api.field_behavior) = OPTIONAL];

  // Optional. The filter to apply to list results.
  string filter = 4 [(google.api.field_behavior) = OPTIONAL];

  // Optional. Specifies the ordering of results following syntax at
  // https://cloud.google.com/apis/design/design_patterns#sorting_order.
  string order_by = 5 [(google.api.field_behavior) = OPTIONAL];
}

// Response message for GameServerClustersService.ListGameServerClusters.
message ListGameServerClustersResponse {
  // The list of game server clusters.
  repeated GameServerCluster game_server_clusters = 1;

  // Token to retrieve the next page of results, or empty if there are no more
  // results in the list.
  string next_page_token = 2;

  // List of locations that could not be reached.
  repeated string unreachable = 4;
}

// Request message for GameServerClustersService.GetGameServerCluster.
message GetGameServerClusterRequest {
  // Required. The name of the game server cluster to retrieve. Uses the form:
  //
  // `projects/{project}/locations/{location}/realms/{realm-id}/gameServerClusters/{cluster}`.
  string name = 1 [
    (google.api.field_behavior) = REQUIRED,
    (google.api.resource_reference) = {
      type: "gameservices.googleapis.com/GameServerCluster"
    }
  ];
}

// Request message for GameServerClustersService.CreateGameServerCluster.
message CreateGameServerClusterRequest {
  // Required. The parent resource name. Uses the form:
  // `projects/{project}/locations/{location}/realms/{realm-id}`.
  string parent = 1 [
    (google.api.field_behavior) = REQUIRED,
    (google.api.resource_reference) = {
      child_type: "gameservices.googleapis.com/GameServerCluster"
    }
  ];

  // Required. The ID of the game server cluster resource to be created.
  string game_server_cluster_id = 2 [(google.api.field_behavior) = REQUIRED];

  // Required. The game server cluster resource to be created.
  GameServerCluster game_server_cluster = 3 [(google.api.field_behavior) = REQUIRED];
}

// Request message for GameServerClustersService.PreviewCreateGameServerCluster.
message PreviewCreateGameServerClusterRequest {
  // Required. The parent resource name. Uses the form:
  // `projects/{project}/locations/{location}/realms/{realm}`.
  string parent = 1 [
    (google.api.field_behavior) = REQUIRED,
    (google.api.resource_reference) = {
      child_type: "gameservices.googleapis.com/GameServerCluster"
    }
  ];

  // Required. The ID of the game server cluster resource to be created.
  string game_server_cluster_id = 2 [(google.api.field_behavior) = REQUIRED];

  // Required. The game server cluster resource to be created.
  GameServerCluster game_server_cluster = 3 [(google.api.field_behavior) = REQUIRED];

  // Optional. The target timestamp to compute the preview.
  google.protobuf.Timestamp preview_time = 4 [(google.api.field_behavior) = OPTIONAL];
}

// Response message for
// GameServerClustersService.PreviewCreateGameServerCluster.
message PreviewCreateGameServerClusterResponse {
  // The ETag of the game server cluster.
  string etag = 2;

  // The target state.
  TargetState target_state = 3;
}

// Request message for GameServerClustersService.DeleteGameServerCluster.
message DeleteGameServerClusterRequest {
  // Required. The name of the game server cluster to delete. Uses the form:
  // `projects/{project}/locations/{location}/gameServerClusters/{cluster}`.
  string name = 1 [
    (google.api.field_behavior) = REQUIRED,
    (google.api.resource_reference) = {
      type: "gameservices.googleapis.com/GameServerCluster"
    }
  ];
}

// Request message for GameServerClustersService.PreviewDeleteGameServerCluster.
message PreviewDeleteGameServerClusterRequest {
  // Required. The name of the game server cluster to delete. Uses the form:
  // `projects/{project}/locations/{location}/gameServerClusters/{cluster}`.
  string name = 1 [
    (google.api.field_behavior) = REQUIRED,
    (google.api.resource_reference) = {
      type: "gameservices.googleapis.com/GameServerCluster"
    }
  ];

  // Optional. The target timestamp to compute the preview.
  google.protobuf.Timestamp preview_time = 2 [(google.api.field_behavior) = OPTIONAL];
}

// Response message for
// GameServerClustersService.PreviewDeleteGameServerCluster.
message PreviewDeleteGameServerClusterResponse {
  // The ETag of the game server cluster.
  string etag = 2;

  // The target state.
  TargetState target_state = 3;
}

// Request message for GameServerClustersService.UpdateGameServerCluster.
message UpdateGameServerClusterRequest {
  // Required. The game server cluster to be updated.
  // Only fields specified in update_mask are updated.
  GameServerCluster game_server_cluster = 1 [(google.api.field_behavior) = REQUIRED];

  // 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
  google.protobuf.FieldMask update_mask = 2 [(google.api.field_behavior) = REQUIRED];
}

// Request message for GameServerClustersService.UpdateGameServerCluster.
message PreviewUpdateGameServerClusterRequest {
  // Required. The game server cluster to be updated.
  // Only fields specified in update_mask are updated.
  GameServerCluster game_server_cluster = 1 [(google.api.field_behavior) = REQUIRED];

  // 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
  google.protobuf.FieldMask update_mask = 2 [(google.api.field_behavior) = REQUIRED];

  // Optional. The target timestamp to compute the preview.
  google.protobuf.Timestamp preview_time = 3 [(google.api.field_behavior) = OPTIONAL];
}

// Response message for GameServerClustersService.PreviewUpdateGameServerCluster
message PreviewUpdateGameServerClusterResponse {
  // The ETag of the game server cluster.
  string etag = 2;

  // The target state.
  TargetState target_state = 3;
}

// The game server cluster connection information.
message GameServerClusterConnectionInfo {
  // The location of the Kubernetes cluster.
  oneof cluster_reference {
    // Reference to the GKE cluster where the game servers are installed.
    GkeClusterReference gke_cluster_reference = 7;
  }

  // Namespace designated on the game server cluster where the Agones game
  // server instances will be created. Existence of the namespace will be
  // validated during creation.
  string namespace = 5;
}

// A reference to a GKE cluster.
message GkeClusterReference {
  // The full or partial name of a GKE cluster, using one of the following
  // forms:
  //  * `projects/{project}/locations/{location}/clusters/{cluster}`
  //  * `locations/{location}/clusters/{cluster}`
  //  * `{cluster}`
  // If project and location are not specified, the project and location of the
  // GameServerCluster resource are used to generate the full name of the
  // GKE cluster.
  string cluster = 1;
}

// A game server cluster resource.
message GameServerCluster {
  option (google.api.resource) = {
    type: "gameservices.googleapis.com/GameServerCluster"
    pattern: "projects/{project}/locations/{location}/realms/{realm}/gameServerClusters/{cluster}"
  };

  // Required. The resource name of the game server cluster. Uses the form:
  //
  // `projects/{project}/locations/{location}/realms/{realm}/gameServerClusters/{cluster}`.
  // For example,
  //
  // `projects/my-project/locations/{location}/realms/zanzibar/gameServerClusters/my-onprem-cluster`.
  string name = 1 [(google.api.field_behavior) = REQUIRED];

  // Output only. The creation time.
  google.protobuf.Timestamp create_time = 2 [(google.api.field_behavior) = OUTPUT_ONLY];

  // Output only. The last-modified time.
  google.protobuf.Timestamp update_time = 3 [(google.api.field_behavior) = OUTPUT_ONLY];

  // The labels associated with this game server cluster. Each label is a
  // key-value pair.
  map<string, string> labels = 4;

  // The game server cluster connection information. This information is used to
  // manage game server clusters.
  GameServerClusterConnectionInfo connection_info = 5;

  // ETag of the resource.
  string etag = 6;

  // Human readable description of the cluster.
  string description = 7;
}
