// Copyright 2021 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.gkehub.v1beta;

import "google/api/annotations.proto";
import "google/api/client.proto";
import "google/api/field_behavior.proto";
import "google/api/resource.proto";
import "google/cloud/gkehub/v1beta/feature.proto";
import "google/longrunning/operations.proto";
import "google/protobuf/field_mask.proto";
import "google/protobuf/timestamp.proto";

option csharp_namespace = "Google.Cloud.GkeHub.V1Beta";
option go_package = "google.golang.org/genproto/googleapis/cloud/gkehub/v1beta;gkehub";
option java_multiple_files = true;
option java_outer_classname = "ServiceProto";
option java_package = "com.google.cloud.gkehub.v1beta";
option php_namespace = "Google\\Cloud\\GkeHub\\V1beta";
option ruby_package = "Google::Cloud::GkeHub::V1beta";

// The GKE Hub service handles the registration of many Kubernetes clusters to
// Google Cloud, and the management of multi-cluster features over those
// clusters.
//
// The GKE Hub service operates on the following resources:
//
// * [Membership][google.cloud.gkehub.v1beta.Membership]
// * [Feature][google.cloud.gkehub.v1beta.Feature]
//
// GKE Hub is currently only available in the global region.
//
// **Membership management may be non-trivial:** it is recommended to use one
// of the Google-provided client libraries or tools where possible when working
// with Membership resources.
service GkeHub {
  option (google.api.default_host) = "gkehub.googleapis.com";
  option (google.api.oauth_scopes) = "https://www.googleapis.com/auth/cloud-platform";

  // Lists Features in a given project and location.
  rpc ListFeatures(ListFeaturesRequest) returns (ListFeaturesResponse) {
    option (google.api.http) = {
      get: "/v1beta/{parent=projects/*/locations/*}/features"
    };
    option (google.api.method_signature) = "parent";
  }

  // Gets details of a single Feature.
  rpc GetFeature(GetFeatureRequest) returns (Feature) {
    option (google.api.http) = {
      get: "/v1beta/{name=projects/*/locations/*/features/*}"
    };
    option (google.api.method_signature) = "name";
  }

  // Adds a new Feature.
  rpc CreateFeature(CreateFeatureRequest) returns (google.longrunning.Operation) {
    option (google.api.http) = {
      post: "/v1beta/{parent=projects/*/locations/*}/features"
      body: "resource"
    };
    option (google.api.method_signature) = "parent,resource,feature_id";
    option (google.longrunning.operation_info) = {
      response_type: "Feature"
      metadata_type: "OperationMetadata"
    };
  }

  // Removes a Feature.
  rpc DeleteFeature(DeleteFeatureRequest) returns (google.longrunning.Operation) {
    option (google.api.http) = {
      delete: "/v1beta/{name=projects/*/locations/*/features/*}"
    };
    option (google.api.method_signature) = "name";
    option (google.longrunning.operation_info) = {
      response_type: "google.protobuf.Empty"
      metadata_type: "OperationMetadata"
    };
  }

  // Updates an existing Feature.
  rpc UpdateFeature(UpdateFeatureRequest) returns (google.longrunning.Operation) {
    option (google.api.http) = {
      patch: "/v1beta/{name=projects/*/locations/*/features/*}"
      body: "resource"
    };
    option (google.api.method_signature) = "name,resource,update_mask";
    option (google.longrunning.operation_info) = {
      response_type: "Feature"
      metadata_type: "OperationMetadata"
    };
  }
}

// Request message for `GkeHub.ListFeatures` method.
message ListFeaturesRequest {
  // The parent (project and location) where the Features will be listed.
  // Specified in the format `projects/*/locations/*`.
  string parent = 1;

  // When requesting a 'page' of resources, `page_size` specifies number of
  // resources to return. If unspecified or set to 0, all resources will
  // be returned.
  int32 page_size = 2;

  // Token returned by previous call to `ListFeatures` which
  // specifies the position in the list from where to continue listing the
  // resources.
  string page_token = 3;

  // Lists Features that match the filter expression, following the syntax
  // outlined in https://google.aip.dev/160.
  //
  // Examples:
  //
  //   - Feature with the name "servicemesh" in project "foo-proj":
  //
  //       name = "projects/foo-proj/locations/global/features/servicemesh"
  //
  //   - Features that have a label called `foo`:
  //
  //       labels.foo:*
  //
  //   - Features that have a label called `foo` whose value is `bar`:
  //
  //       labels.foo = bar
  string filter = 4;

  // One or more fields to compare and use to sort the output.
  // See https://google.aip.dev/132#ordering.
  string order_by = 5;
}

// Response message for the `GkeHub.ListFeatures` method.
message ListFeaturesResponse {
  // The list of matching Features
  repeated Feature resources = 1;

  // A token to request the next page of resources from the
  // `ListFeatures` method. The value of an empty string means
  // that there are no more resources to return.
  string next_page_token = 2;
}

// Request message for `GkeHub.GetFeature` method.
message GetFeatureRequest {
  // The Feature resource name in the format
  // `projects/*/locations/*/features/*`
  string name = 1;
}

// Request message for the `GkeHub.CreateFeature` method.
message CreateFeatureRequest {
  // The parent (project and location) where the Feature will be created.
  // Specified in the format `projects/*/locations/*`.
  string parent = 1;

  // The ID of the feature to create.
  string feature_id = 2;

  // The Feature resource to create.
  Feature resource = 3;

  // Optional. A request ID to identify requests. Specify a unique request ID
  // so that if you must retry your request, the server will know to ignore
  // the request if it has already been completed. The server will guarantee
  // that for at least 60 minutes after the first request.
  //
  // For example, consider a situation where you make an initial request and
  // the request times out. If you make the request again with the same request
  // ID, the server can check if original operation with the same request ID
  // was received, and if so, will ignore the second request. This prevents
  // clients from accidentally creating duplicate commitments.
  //
  // The request ID must be a valid UUID with the exception that zero UUID is
  // not supported (00000000-0000-0000-0000-000000000000).
  string request_id = 4 [(google.api.field_behavior) = OPTIONAL];
}

// Request message for `GkeHub.DeleteFeature` method.
message DeleteFeatureRequest {
  // The Feature resource name in the format
  // `projects/*/locations/*/features/*`.
  string name = 1;

  // If set to true, the delete will ignore any outstanding resources for
  // this Feature (that is, `FeatureState.has_resources` is set to true). These
  // resources will NOT be cleaned up or modified in any way.
  bool force = 2;

  // Optional. A request ID to identify requests. Specify a unique request ID
  // so that if you must retry your request, the server will know to ignore
  // the request if it has already been completed. The server will guarantee
  // that for at least 60 minutes after the first request.
  //
  // For example, consider a situation where you make an initial request and
  // the request times out. If you make the request again with the same request
  // ID, the server can check if original operation with the same request ID
  // was received, and if so, will ignore the second request. This prevents
  // clients from accidentally creating duplicate commitments.
  //
  // The request ID must be a valid UUID with the exception that zero UUID is
  // not supported (00000000-0000-0000-0000-000000000000).
  string request_id = 3 [(google.api.field_behavior) = OPTIONAL];
}

// Request message for `GkeHub.UpdateFeature` method.
message UpdateFeatureRequest {
  // The Feature resource name in the format
  // `projects/*/locations/*/features/*`.
  string name = 1;

  // Mask of fields to update.
  google.protobuf.FieldMask update_mask = 2;

  // Only fields specified in update_mask are updated.
  // If you specify a field in the update_mask but don't specify its value here
  // that field will be deleted.
  // If you are updating a map field, set the value of a key to null or empty
  // string to delete the key from the map. It's not possible to update a key's
  // value to the empty string.
  // If you specify the update_mask to be a special path "*", fully replaces all
  // user-modifiable fields to match `resource`.
  Feature resource = 3;

  // Optional. A request ID to identify requests. Specify a unique request ID
  // so that if you must retry your request, the server will know to ignore
  // the request if it has already been completed. The server will guarantee
  // that for at least 60 minutes after the first request.
  //
  // For example, consider a situation where you make an initial request and
  // the request times out. If you make the request again with the same request
  // ID, the server can check if original operation with the same request ID
  // was received, and if so, will ignore the second request. This prevents
  // clients from accidentally creating duplicate commitments.
  //
  // The request ID must be a valid UUID with the exception that zero UUID is
  // not supported (00000000-0000-0000-0000-000000000000).
  string request_id = 4 [(google.api.field_behavior) = OPTIONAL];
}

// Represents the metadata of the long-running operation.
message OperationMetadata {
  // Output only. The time the operation was created.
  google.protobuf.Timestamp create_time = 1 [(google.api.field_behavior) = OUTPUT_ONLY];

  // Output only. The time the operation finished running.
  google.protobuf.Timestamp end_time = 2 [(google.api.field_behavior) = OUTPUT_ONLY];

  // Output only. Server-defined resource path for the target of the operation.
  string target = 3 [(google.api.field_behavior) = OUTPUT_ONLY];

  // Output only. Name of the verb executed by the operation.
  string verb = 4 [(google.api.field_behavior) = OUTPUT_ONLY];

  // Output only. Human-readable status of the operation, if any.
  string status_detail = 5 [(google.api.field_behavior) = OUTPUT_ONLY];

  // Output only. Identifies whether the user has requested cancellation
  // of the operation. Operations that have successfully been cancelled
  // have [Operation.error][] value with a [google.rpc.Status.code][google.rpc.Status.code] of 1,
  // corresponding to `Code.CANCELLED`.
  bool cancel_requested = 6 [(google.api.field_behavior) = OUTPUT_ONLY];

  // Output only. API version used to start the operation.
  string api_version = 7 [(google.api.field_behavior) = OUTPUT_ONLY];
}
