// Copyright 2016 Google Inc.
//
// 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.bigtable.admin.v2;

import "google/api/annotations.proto";
import "google/bigtable/admin/v2/instance.proto";
import "google/longrunning/operations.proto";
import "google/protobuf/empty.proto";
import "google/protobuf/timestamp.proto";

option go_package = "google.golang.org/genproto/googleapis/bigtable/admin/v2;admin";
option java_multiple_files = true;
option java_outer_classname = "BigtableInstanceAdminProto";
option java_package = "com.google.bigtable.admin.v2";


// Service for creating, configuring, and deleting Cloud Bigtable Instances and
// Clusters. Provides access to the Instance and Cluster schemas only, not the
// tables' metadata or data stored in those tables.
service BigtableInstanceAdmin {
  // Create an instance within a project.
  rpc CreateInstance(CreateInstanceRequest) returns (google.longrunning.Operation) {
    option (google.api.http) = { post: "/v2/{parent=projects/*}/instances" body: "*" };
  }

  // Gets information about an instance.
  rpc GetInstance(GetInstanceRequest) returns (Instance) {
    option (google.api.http) = { get: "/v2/{name=projects/*/instances/*}" };
  }

  // Lists information about instances in a project.
  rpc ListInstances(ListInstancesRequest) returns (ListInstancesResponse) {
    option (google.api.http) = { get: "/v2/{parent=projects/*}/instances" };
  }

  // Updates an instance within a project.
  rpc UpdateInstance(Instance) returns (Instance) {
    option (google.api.http) = { put: "/v2/{name=projects/*/instances/*}" body: "*" };
  }

  // Delete an instance from a project.
  rpc DeleteInstance(DeleteInstanceRequest) returns (google.protobuf.Empty) {
    option (google.api.http) = { delete: "/v2/{name=projects/*/instances/*}" };
  }

  // Creates a cluster within an instance.
  rpc CreateCluster(CreateClusterRequest) returns (google.longrunning.Operation) {
    option (google.api.http) = { post: "/v2/{parent=projects/*/instances/*}/clusters" body: "cluster" };
  }

  // Gets information about a cluster.
  rpc GetCluster(GetClusterRequest) returns (Cluster) {
    option (google.api.http) = { get: "/v2/{name=projects/*/instances/*/clusters/*}" };
  }

  // Lists information about clusters in an instance.
  rpc ListClusters(ListClustersRequest) returns (ListClustersResponse) {
    option (google.api.http) = { get: "/v2/{parent=projects/*/instances/*}/clusters" };
  }

  // Updates a cluster within an instance.
  rpc UpdateCluster(Cluster) returns (google.longrunning.Operation) {
    option (google.api.http) = { put: "/v2/{name=projects/*/instances/*/clusters/*}" body: "*" };
  }

  // Deletes a cluster from an instance.
  rpc DeleteCluster(DeleteClusterRequest) returns (google.protobuf.Empty) {
    option (google.api.http) = { delete: "/v2/{name=projects/*/instances/*/clusters/*}" };
  }
}

// Request message for BigtableInstanceAdmin.CreateInstance.
message CreateInstanceRequest {
  // The unique name of the project in which to create the new instance.
  // Values are of the form `projects/<project>`.
  string parent = 1;

  // The ID to be used when referring to the new instance within its project,
  // e.g., just `myinstance` rather than
  // `projects/myproject/instances/myinstance`.
  string instance_id = 2;

  // The instance to create.
  // Fields marked `OutputOnly` must be left blank.
  Instance instance = 3;

  // The clusters to be created within the instance, mapped by desired
  // cluster ID, e.g., just `mycluster` rather than
  // `projects/myproject/instances/myinstance/clusters/mycluster`.
  // Fields marked `OutputOnly` must be left blank.
  // Currently exactly one cluster must be specified.
  map<string, Cluster> clusters = 4;
}

// Request message for BigtableInstanceAdmin.GetInstance.
message GetInstanceRequest {
  // The unique name of the requested instance. Values are of the form
  // `projects/<project>/instances/<instance>`.
  string name = 1;
}

// Request message for BigtableInstanceAdmin.ListInstances.
message ListInstancesRequest {
  // The unique name of the project for which a list of instances is requested.
  // Values are of the form `projects/<project>`.
  string parent = 1;

  // The value of `next_page_token` returned by a previous call.
  string page_token = 2;
}

// Response message for BigtableInstanceAdmin.ListInstances.
message ListInstancesResponse {
  // The list of requested instances.
  repeated Instance instances = 1;

  // Locations from which Instance information could not be retrieved,
  // due to an outage or some other transient condition.
  // Instances whose Clusters are all in one of the failed locations
  // may be missing from `instances`, and Instances with at least one
  // Cluster in a failed location may only have partial information returned.
  repeated string failed_locations = 2;

  // Set if not all instances could be returned in a single response.
  // Pass this value to `page_token` in another request to get the next
  // page of results.
  string next_page_token = 3;
}

// Request message for BigtableInstanceAdmin.DeleteInstance.
message DeleteInstanceRequest {
  // The unique name of the instance to be deleted.
  // Values are of the form `projects/<project>/instances/<instance>`.
  string name = 1;
}

// Request message for BigtableInstanceAdmin.CreateCluster.
message CreateClusterRequest {
  // The unique name of the instance in which to create the new cluster.
  // Values are of the form
  // `projects/<project>/instances/<instance>`.
  string parent = 1;

  // The ID to be used when referring to the new cluster within its instance,
  // e.g., just `mycluster` rather than
  // `projects/myproject/instances/myinstance/clusters/mycluster`.
  string cluster_id = 2;

  // The cluster to be created.
  // Fields marked `OutputOnly` must be left blank.
  Cluster cluster = 3;
}

// Request message for BigtableInstanceAdmin.GetCluster.
message GetClusterRequest {
  // The unique name of the requested cluster. Values are of the form
  // `projects/<project>/instances/<instance>/clusters/<cluster>`.
  string name = 1;
}

// Request message for BigtableInstanceAdmin.ListClusters.
message ListClustersRequest {
  // The unique name of the instance for which a list of clusters is requested.
  // Values are of the form `projects/<project>/instances/<instance>`.
  // Use `<instance> = '-'` to list Clusters for all Instances in a project,
  // e.g., `projects/myproject/instances/-`.
  string parent = 1;

  // The value of `next_page_token` returned by a previous call.
  string page_token = 2;
}

// Response message for BigtableInstanceAdmin.ListClusters.
message ListClustersResponse {
  // The list of requested clusters.
  repeated Cluster clusters = 1;

  // Locations from which Cluster information could not be retrieved,
  // due to an outage or some other transient condition.
  // Clusters from these locations may be missing from `clusters`,
  // or may only have partial information returned.
  repeated string failed_locations = 2;

  // Set if not all clusters could be returned in a single response.
  // Pass this value to `page_token` in another request to get the next
  // page of results.
  string next_page_token = 3;
}

// Request message for BigtableInstanceAdmin.DeleteCluster.
message DeleteClusterRequest {
  // The unique name of the cluster to be deleted. Values are of the form
  // `projects/<project>/instances/<instance>/clusters/<cluster>`.
  string name = 1;
}

// The metadata for the Operation returned by CreateInstance.
message CreateInstanceMetadata {
  // The request that prompted the initiation of this CreateInstance operation.
  CreateInstanceRequest original_request = 1;

  // The time at which the original request was received.
  google.protobuf.Timestamp request_time = 2;

  // The time at which the operation failed or was completed successfully.
  google.protobuf.Timestamp finish_time = 3;
}

// The metadata for the Operation returned by UpdateCluster.
message UpdateClusterMetadata {
  // The request that prompted the initiation of this UpdateCluster operation.
  Cluster original_request = 1;

  // The time at which the original request was received.
  google.protobuf.Timestamp request_time = 2;

  // The time at which the operation failed or was completed successfully.
  google.protobuf.Timestamp finish_time = 3;
}
