// Copyright 2026 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.saasplatform.saasservicemgmt.v1beta1;

import "google/api/field_behavior.proto";
import "google/api/resource.proto";
import "google/protobuf/timestamp.proto";

option csharp_namespace = "Google.Cloud.SaasPlatform.SaasServiceMgmt.V1Beta1";
option go_package = "cloud.google.com/go/saasplatform/saasservicemgmt/apiv1beta1/saasservicemgmtpb;saasservicemgmtpb";
option java_multiple_files = true;
option java_outer_classname = "CommonProto";
option java_package = "com.google.cloud.saasplatform.saasservicemgmt.v1beta1";
option php_namespace = "Google\\Cloud\\SaasPlatform\\SaasServiceMgmt\\V1beta1";
option ruby_package = "Google::Cloud::SaasPlatform::SaasServiceMgmt::V1beta1";

// UnitOperationErrorCategory describes the error category of the unit
// operation.
enum UnitOperationErrorCategory {
  // Unit operation error category is unspecified
  UNIT_OPERATION_ERROR_CATEGORY_UNSPECIFIED = 0;

  // Unit operation error category is not applicable, or it is not an error
  NOT_APPLICABLE = 1;

  // Unit operation error category is fatal
  FATAL = 2;

  // Unit operation error category is retriable
  RETRIABLE = 3;

  // Unit operation error category is ignorable
  IGNORABLE = 4;

  // Unit operation error category is standard, counts towards Rollout error
  // budget
  STANDARD = 5;
}

// Blueprints are OCI Images that contain all of the artifacts needed to
// provision a unit. Metadata such as, type of the engine used to actuate the
// blueprint (e.g. terraform, helm etc) and version will come from the image
// manifest. If the hostname is omitted, it will be assumed to be the regional
// path to Artifact Registry (eg. us-east1-docker.pkg.dev).
message Blueprint {
  // Optional. Immutable. URI to a blueprint used by the Unit (required unless
  // unitKind or release is set).
  string package = 1 [
    (google.api.field_behavior) = OPTIONAL,
    (google.api.field_behavior) = IMMUTABLE
  ];

  // Output only. Type of the engine used to actuate the blueprint. e.g.
  // terraform, helm etc.
  string engine = 2 [(google.api.field_behavior) = OUTPUT_ONLY];

  // Output only. Version metadata if present on the blueprint.
  string version = 3 [(google.api.field_behavior) = OUTPUT_ONLY];
}

// UnitVariable describes a parameter for a Unit.
message UnitVariable {
  // Enumeration of variable types.
  // `STRUCT` and `LIST` values should be JSON-encoded strings.
  enum Type {
    // Variable type is unspecified.
    TYPE_UNSPECIFIED = 0;

    // Variable type is string.
    STRING = 1;

    // Variable type is int.
    INT = 2;

    // Variable type is bool.
    BOOL = 3;

    // Variable type is struct.
    STRUCT = 4;

    // Variable type is list.
    LIST = 5;
  }

  // Required. Immutable. Name of the variable from actuation configs.
  string variable = 1 [
    (google.api.field_behavior) = REQUIRED,
    (google.api.field_behavior) = IMMUTABLE
  ];

  // Optional. Immutable. Name of a supported variable type. Supported types are
  // string, int, bool.
  Type type = 2 [
    (google.api.field_behavior) = OPTIONAL,
    (google.api.field_behavior) = IMMUTABLE
  ];

  // Optional. String encoded value for the variable.
  string value = 3 [(google.api.field_behavior) = OPTIONAL];
}

// UnitCondition describes the status of an Unit. UnitCondition is individual
// components that contribute to an overall state.
message UnitCondition {
  // Enumeration of condition statuses.
  enum Status {
    // Condition status is unspecified.
    STATUS_UNSPECIFIED = 0;

    // Condition is unknown.
    STATUS_UNKNOWN = 1;

    // Condition is true.
    STATUS_TRUE = 2;

    // Condition is false.
    STATUS_FALSE = 3;
  }

  // Enumeration of condition types.
  enum Type {
    // Condition type is unspecified.
    TYPE_UNSPECIFIED = 0;

    // Condition type is ready.
    TYPE_READY = 1;

    // Condition type is updating.
    TYPE_UPDATING = 2;

    // Condition type is provisioned.
    TYPE_PROVISIONED = 3;

    // Condition type is operationError.
    // True when the last unit operation fails with a non-ignorable error.
    TYPE_OPERATION_ERROR = 4;

    // Indicates if AppHub app has been created or if Apphub app has already
    // existed.
    TYPE_APP_CREATED_OR_ALREADY_EXISTS = 5;

    // Indicates if services and workloads have been registered with AppHub.
    TYPE_APP_COMPONENTS_REGISTERED = 6;
  }

  // Required. Status of the condition.
  Status status = 1 [(google.api.field_behavior) = REQUIRED];

  // Required. Type of the condition.
  Type type = 2 [(google.api.field_behavior) = REQUIRED];

  // Required. Last time the condition transited from one status to another.
  google.protobuf.Timestamp last_transition_time = 3
      [(google.api.field_behavior) = REQUIRED];

  // Required. Human readable message indicating details about the last
  // transition.
  string message = 4 [(google.api.field_behavior) = REQUIRED];

  // Required. Brief reason for the condition's last transition.
  string reason = 5 [(google.api.field_behavior) = REQUIRED];
}

// UnitOperationCondition describes the status of an Unit Operation.
// UnitOperationCondition is individual components that contribute to an overall
// state.
message UnitOperationCondition {
  // Enumeration of condition statuses.
  enum Status {
    // Condition status is unspecified.
    STATUS_UNSPECIFIED = 0;

    // Condition is unknown.
    STATUS_UNKNOWN = 1;

    // Condition is true.
    STATUS_TRUE = 2;

    // Condition is false.
    STATUS_FALSE = 3;
  }

  // Enumeration of condition types.
  enum Type {
    // Condition type is unspecified.
    TYPE_UNSPECIFIED = 0;

    // Condition type is scheduled.
    TYPE_SCHEDULED = 2;

    // Condition type is running.
    TYPE_RUNNING = 3;

    // Condition type is succeeded.
    TYPE_SUCCEEDED = 4;

    // Condition type is cancelled.
    TYPE_CANCELLED = 5;

    // Indicates if AppHub app has been created.
    TYPE_APP_CREATED = 6;

    // Indicates if services and workloads have been registered with AppHub.
    TYPE_APP_COMPONENTS_REGISTERED = 7;

    // Indicates if the UnitOperation's core workload execution completed
    // successfully.
    // The workload is the core execution operation performed for a
    // UnitOperation (e.g., provisioning, updating, or deprovisioning
    // resources) excluding post-operation checks.
    TYPE_WORKLOAD_SUCCEEDED = 8;
  }

  // Required. Status of the condition.
  Status status = 1 [(google.api.field_behavior) = REQUIRED];

  // Required. Type of the condition.
  Type type = 2 [(google.api.field_behavior) = REQUIRED];

  // Required. Last time the condition transited from one status to another.
  google.protobuf.Timestamp last_transition_time = 3
      [(google.api.field_behavior) = REQUIRED];

  // Required. Human readable message indicating details about the last
  // transition.
  string message = 4 [(google.api.field_behavior) = REQUIRED];

  // Required. Brief reason for the condition's last transition.
  string reason = 5 [(google.api.field_behavior) = REQUIRED];
}

// SaasCondition describes the status of a Saas.
message SaasCondition {
  // Enumeration of condition statuses.
  enum Status {
    // Condition status is unspecified.
    STATUS_UNSPECIFIED = 0;

    // Condition is unknown.
    STATUS_UNKNOWN = 1;

    // Condition is true.
    STATUS_TRUE = 2;

    // Condition is false.
    STATUS_FALSE = 3;
  }

  // Enumeration of condition types.
  enum Type {
    // Condition type is unspecified.
    TYPE_UNSPECIFIED = 0;

    // Condition type is ready.
    TYPE_READY = 1;

    // Condition type is synchronized.
    TYPE_SYNCHRONIZED = 2;
  }

  // Required. Status of the condition.
  Status status = 1 [(google.api.field_behavior) = REQUIRED];

  // Required. Type of the condition.
  Type type = 6 [(google.api.field_behavior) = REQUIRED];

  // Required. Last time the condition transited from one status to another.
  google.protobuf.Timestamp last_transition_time = 3
      [(google.api.field_behavior) = REQUIRED];

  // Required. Human readable message indicating details about the last
  // transition.
  string message = 4 [(google.api.field_behavior) = REQUIRED];

  // Required. Brief reason for the condition's last transition.
  string reason = 5 [(google.api.field_behavior) = REQUIRED];
}

// Represents the aggregation of a set of population of like records by a
// certain group. For example, a collection of unit counts can be aggregated and
// grouped by their state.
message Aggregate {
  // Required. Group by which to aggregate.
  string group = 1 [(google.api.field_behavior) = REQUIRED];

  // Required. Number of records in the group.
  int32 count = 2 [(google.api.field_behavior) = REQUIRED];
}
