// Copyright 2025 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.run.v2;

import "google/api/resource.proto";

option go_package = "cloud.google.com/go/run/apiv2/runpb;runpb";
option java_multiple_files = true;
option java_outer_classname = "InstanceSplitProto";
option java_package = "com.google.cloud.run.v2";

// Holds a single instance split entry for the Worker. Allocations can be done
// to a specific Revision name, or pointing to the latest Ready Revision.
message InstanceSplit {
  // The allocation type for this instance split.
  InstanceSplitAllocationType type = 1;

  // Revision to which to assign this portion of instances, if split allocation
  // is by revision.
  string revision = 2 [
    (google.api.resource_reference) = { type: "run.googleapis.com/Revision" }
  ];

  // Specifies percent of the instance split to this Revision.
  // This defaults to zero if unspecified.
  int32 percent = 3;
}

// Represents the observed state of a single `InstanceSplit` entry.
message InstanceSplitStatus {
  // The allocation type for this instance split.
  InstanceSplitAllocationType type = 1;

  // Revision to which this instance split is assigned.
  string revision = 2 [
    (google.api.resource_reference) = { type: "run.googleapis.com/Revision" }
  ];

  // Specifies percent of the instance split to this Revision.
  int32 percent = 3;
}

// The type of instance split allocation.
enum InstanceSplitAllocationType {
  // Unspecified instance allocation type.
  INSTANCE_SPLIT_ALLOCATION_TYPE_UNSPECIFIED = 0;

  // Allocates instances to the Service's latest ready Revision.
  INSTANCE_SPLIT_ALLOCATION_TYPE_LATEST = 1;

  // Allocates instances to a Revision by name.
  INSTANCE_SPLIT_ALLOCATION_TYPE_REVISION = 2;
}
