// 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/field_info.proto";
import "google/api/resource.proto";
import "google/cloud/saasplatform/saasservicemgmt/v1beta1/common.proto";
import "google/protobuf/timestamp.proto";
import "google/rpc/status.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 = "SaasDeploymentsResourcesProto";
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";
option (google.api.resource_definition) = {
  type: "apphub.googleapis.com/Application"
  pattern: "projects/{project}/locations/{location}/applications/{application}"
};
option (google.api.resource_definition) = {
  type: "designcenter.googleapis.com/ApplicationTemplate"
  pattern: "projects/{project}/locations/{location}/spaces/{space}/applicationTemplates/{applicationTemplate}"
  pattern: "projects/{project}/locations/{location}/workspaces/{workspace}/applicationTemplates/{applicationTemplate}"
};
option (google.api.resource_definition) = {
  type: "designcenter.googleapis.com/ApplicationTemplateRevision"
  pattern: "projects/{project}/locations/{location}/spaces/{space}/applicationTemplates/{application_template}/revisions/{revision}"
};

// Location information that the service is available in.
message Location {
  // Optional. Name of location.
  string name = 1 [(google.api.field_behavior) = OPTIONAL];
}

// Saas is a representation of a SaaS service managed by the Producer.
message Saas {
  option (google.api.resource) = {
    type: "saasservicemgmt.googleapis.com/Saas"
    pattern: "projects/{project}/locations/{location}/saas/{saas}"
    plural: "saas"
    singular: "saas"
  };

  // State of the Saas.
  enum State {
    option allow_alias = true;

    // State type is unspecified.
    STATE_TYPE_UNSPECIFIED = 0;

    // The Saas is ready
    STATE_ACTIVE = 1;

    // In the process of importing, synchronizing or replicating
    // ApplicationTemplates
    STATE_RUNNING = 2;

    // Failure during process of importing, synchronizing or replicating
    // ApplicationTemplate processing
    STATE_FAILED = 3;

    // Deprecated: Use STATE_ACTIVE.
    ACTIVE = 1 [deprecated = true];

    // Deprecated: Use STATE_RUNNING.
    RUNNING = 2 [deprecated = true];

    // Deprecated: Use STATE_FAILED.
    FAILED = 3 [deprecated = true];
  }

  // Identifier. The resource name (full URI of the resource) following the
  // standard naming scheme:
  //
  //   "projects/{project}/locations/{location}/saas/{saas}"
  string name = 1 [(google.api.field_behavior) = IDENTIFIER];

  // Optional. List of locations that the service is available in. Rollout
  // refers to the list to generate a rollout plan.
  repeated Location locations = 4 [(google.api.field_behavior) = OPTIONAL];

  // Reference to composite ApplicationTemplate.
  // When specified, the template components will be imported into their
  // equivalent UnitKind, Release and Blueprint resources.
  // Deleted references will not delete imported resources.
  // Should only be specified on source regions, and be unspecified on replica
  // regions.
  CompositeRef application_template = 5;

  // Output only. Name of repository in Artifact Registry for system-generated
  // Blueprints, eg. Blueprints of imported ApplicationTemplates.
  string blueprint_repo = 6 [(google.api.field_behavior) = OUTPUT_ONLY];

  // Output only. State of the Saas.
  // It is always in ACTIVE state if the application_template is empty.
  State state = 7 [(google.api.field_behavior) = OUTPUT_ONLY];

  // Output only. A set of conditions which indicate the various conditions this
  // resource can have.
  repeated SaasCondition conditions = 8
      [(google.api.field_behavior) = OUTPUT_ONLY];

  // Output only. If the state is FAILED, the corresponding error code and
  // message. Defaults to code=OK for all other states.
  google.rpc.Status error = 9 [(google.api.field_behavior) = OUTPUT_ONLY];

  // Optional. The labels on the resource, which can be used for categorization.
  // similar to Kubernetes resource labels.
  map<string, string> labels = 10401 [(google.api.field_behavior) = OPTIONAL];

  // Optional. Annotations is an unstructured key-value map stored with a
  // resource that may be set by external tools to store and retrieve arbitrary
  // metadata. They are not queryable and should be preserved when modifying
  // objects.
  //
  // More info: https://kubernetes.io/docs/user-guide/annotations
  map<string, string> annotations = 10402
      [(google.api.field_behavior) = OPTIONAL];

  // Output only. The unique identifier of the resource. UID is unique in the
  // time and space for this resource within the scope of the service. It is
  // typically generated by the server on successful creation of a resource
  // and must not be changed. UID is used to uniquely identify resources
  // with resource name reuses. This should be a UUID4.
  string uid = 10201 [
    (google.api.field_info).format = UUID4,
    (google.api.field_behavior) = OUTPUT_ONLY
  ];

  // Output only. An opaque value that uniquely identifies a version or
  // generation of a resource. It can be used to confirm that the client
  // and server agree on the ordering of a resource being written.
  string etag = 10202 [(google.api.field_behavior) = OUTPUT_ONLY];

  // Output only. The timestamp when the resource was created.
  google.protobuf.Timestamp create_time = 10303
      [(google.api.field_behavior) = OUTPUT_ONLY];

  // Output only. The timestamp when the resource was last updated. Any
  // change to the resource made by users must refresh this value.
  // Changes to a resource made by the service should refresh this value.
  google.protobuf.Timestamp update_time = 10304
      [(google.api.field_behavior) = OUTPUT_ONLY];
}

// Tenant represents the service producer side of an instance of the
// service created based on a request from a consumer. In a typical scenario a
// Tenant has a one-to-one mapping with a resource given out to a service
// consumer.
//
// Example:
//
//    tenant:
//      name: "projects/svc1/locations/loc/tenants/inst-068afff8"
//      consumer_resource: "projects/gshoe/locations/loc/shoes/black-shoe"
message Tenant {
  option (google.api.resource) = {
    type: "saasservicemgmt.googleapis.com/Tenant"
    pattern: "projects/{project}/locations/{location}/tenants/{tenant}"
    plural: "tenants"
    singular: "tenant"
  };

  // Identifier. The resource name (full URI of the resource) following the
  // standard naming scheme:
  //
  //   "projects/{project}/locations/{location}/tenants/{tenant}"
  string name = 1 [(google.api.field_behavior) = IDENTIFIER];

  // Optional. Immutable. A reference to the consumer resource this SaaS Tenant
  // is representing.
  //
  // The relationship with a consumer resource can be used by App Lifecycle
  // Manager for retrieving consumer-defined settings and policies such as
  // maintenance policies (using Unified Maintenance Policy API).
  string consumer_resource = 2 [
    (google.api.field_behavior) = OPTIONAL,
    (google.api.field_behavior) = IMMUTABLE
  ];

  // Required. Immutable. A reference to the Saas that defines the product
  // (managed service) that the producer wants to manage with App Lifecycle
  // Manager. Part of the App Lifecycle Manager common data model.
  string saas = 3 [
    (google.api.field_behavior) = REQUIRED,
    (google.api.field_behavior) = IMMUTABLE,
    (google.api.resource_reference) = {
      type: "saasservicemgmt.googleapis.com/Saas"
    }
  ];

  // Optional. The labels on the resource, which can be used for categorization.
  // similar to Kubernetes resource labels.
  map<string, string> labels = 10401 [(google.api.field_behavior) = OPTIONAL];

  // Optional. Annotations is an unstructured key-value map stored with a
  // resource that may be set by external tools to store and retrieve arbitrary
  // metadata. They are not queryable and should be preserved when modifying
  // objects.
  //
  // More info: https://kubernetes.io/docs/user-guide/annotations
  map<string, string> annotations = 10402
      [(google.api.field_behavior) = OPTIONAL];

  // Output only. The unique identifier of the resource. UID is unique in the
  // time and space for this resource within the scope of the service. It is
  // typically generated by the server on successful creation of a resource
  // and must not be changed. UID is used to uniquely identify resources
  // with resource name reuses. This should be a UUID4.
  string uid = 10201 [
    (google.api.field_info).format = UUID4,
    (google.api.field_behavior) = OUTPUT_ONLY
  ];

  // Output only. An opaque value that uniquely identifies a version or
  // generation of a resource. It can be used to confirm that the client
  // and server agree on the ordering of a resource being written.
  string etag = 10202 [(google.api.field_behavior) = OUTPUT_ONLY];

  // Output only. The timestamp when the resource was created.
  google.protobuf.Timestamp create_time = 10303
      [(google.api.field_behavior) = OUTPUT_ONLY];

  // Output only. The timestamp when the resource was last updated. Any
  // change to the resource made by users must refresh this value.
  // Changes to a resource made by the service should refresh this value.
  google.protobuf.Timestamp update_time = 10304
      [(google.api.field_behavior) = OUTPUT_ONLY];
}

// Definition of a Unit. Units belonging to the same UnitKind are managed
// together; for example they follow the same release model (blueprints,
// versions etc.) and are typically rolled out together.
message UnitKind {
  option (google.api.resource) = {
    type: "saasservicemgmt.googleapis.com/UnitKind"
    pattern: "projects/{project}/locations/{location}/unitKinds/{unitKind}"
    plural: "unitKinds"
    singular: "unitKind"
  };

  // Identifier. The resource name (full URI of the resource) following the
  // standard naming scheme:
  //
  //   "projects/{project}/locations/{location}/unitKinds/{unitKind}"
  string name = 1 [(google.api.field_behavior) = IDENTIFIER];

  // Optional. A reference to the Release object to use as default for creating
  // new units of this UnitKind (optional).
  //
  // If not specified, a new unit must explicitly reference which release to use
  // for its creation.
  string default_release = 2 [
    (google.api.field_behavior) = OPTIONAL,
    (google.api.resource_reference) = {
      type: "saasservicemgmt.googleapis.com/Release"
    }
  ];

  // Optional. Immutable. List of other unit kinds that this release will depend
  // on. Dependencies will be automatically provisioned if not found.
  // Maximum 10.
  repeated Dependency dependencies = 4 [
    (google.api.field_behavior) = OPTIONAL,
    (google.api.field_behavior) = IMMUTABLE
  ];

  // Optional. List of inputVariables for this release that will either be
  // retrieved from a dependency’s outputVariables, or will be passed on to a
  // dependency’s inputVariables. Maximum 100.
  repeated VariableMapping input_variable_mappings = 5
      [(google.api.field_behavior) = OPTIONAL];

  // Optional. List of outputVariables for this unit kind will be passed to this
  // unit's outputVariables. Maximum 100.
  repeated VariableMapping output_variable_mappings = 6
      [(google.api.field_behavior) = OPTIONAL];

  // Required. Immutable. A reference to the Saas that defines the product
  // (managed service) that the producer wants to manage with App Lifecycle
  // Manager. Part of the App Lifecycle Manager common data model. Immutable
  // once set.
  string saas = 8 [
    (google.api.field_behavior) = REQUIRED,
    (google.api.field_behavior) = IMMUTABLE,
    (google.api.resource_reference) = {
      type: "saasservicemgmt.googleapis.com/Saas"
    }
  ];

  // Output only. Reference to component and revision in a composite
  // ApplicationTemplate.
  ComponentRef application_template_component = 10
      [(google.api.field_behavior) = OUTPUT_ONLY];

  // AppParams contains the parameters for creating an AppHub Application.
  AppParams app_params = 11;

  // Optional. The labels on the resource, which can be used for categorization.
  // similar to Kubernetes resource labels.
  map<string, string> labels = 10401 [(google.api.field_behavior) = OPTIONAL];

  // Optional. Annotations is an unstructured key-value map stored with a
  // resource that may be set by external tools to store and retrieve arbitrary
  // metadata. They are not queryable and should be preserved when modifying
  // objects.
  //
  // More info: https://kubernetes.io/docs/user-guide/annotations
  map<string, string> annotations = 10402
      [(google.api.field_behavior) = OPTIONAL];

  // Output only. The unique identifier of the resource. UID is unique in the
  // time and space for this resource within the scope of the service. It is
  // typically generated by the server on successful creation of a resource
  // and must not be changed. UID is used to uniquely identify resources
  // with resource name reuses. This should be a UUID4.
  string uid = 10201 [
    (google.api.field_info).format = UUID4,
    (google.api.field_behavior) = OUTPUT_ONLY
  ];

  // Output only. An opaque value that uniquely identifies a version or
  // generation of a resource. It can be used to confirm that the client
  // and server agree on the ordering of a resource being written.
  string etag = 10202 [(google.api.field_behavior) = OUTPUT_ONLY];

  // Output only. The timestamp when the resource was created.
  google.protobuf.Timestamp create_time = 10303
      [(google.api.field_behavior) = OUTPUT_ONLY];

  // Output only. The timestamp when the resource was last updated. Any
  // change to the resource made by users must refresh this value.
  // Changes to a resource made by the service should refresh this value.
  google.protobuf.Timestamp update_time = 10304
      [(google.api.field_behavior) = OUTPUT_ONLY];
}

// A unit of deployment that has its lifecycle via a CRUD API using an actuation
// engine under the hood (e.g. based on Terraform, Helm or a custom
// implementation provided by a service producer). A building block of a SaaS
// Tenant.
message Unit {
  option (google.api.resource) = {
    type: "saasservicemgmt.googleapis.com/Unit"
    pattern: "projects/{project}/locations/{location}/units/{unit}"
    plural: "units"
    singular: "unit"
  };

  // Captures requested directives for performing future maintenance on the
  // unit. This includes a request for the unit to skip maintenance for a period
  // of time and remain pinned to its current release as well as controls for
  // postponing maintenance scheduled in future.
  message MaintenanceSettings {
    // Optional. If present, it fixes the release on the unit until the given
    // time; i.e. changes to the release field will be rejected. Rollouts should
    // and will also respect this by not requesting an upgrade in the first
    // place.
    google.protobuf.Timestamp pinned_until_time = 1
        [(google.api.field_behavior) = OPTIONAL];
  }

  // UnitState annotates what is the current state of the unit itself.
  enum UnitState {
    // Unspecified state.
    UNIT_STATE_UNSPECIFIED = 0;

    // Unit is not provisioned.
    UNIT_STATE_NOT_PROVISIONED = 1;

    // Unit is being provisioned.
    UNIT_STATE_PROVISIONING = 2;

    // Unit is being updated. This is typically when a unit is being upgraded to
    // a new release or some of the input variables on the Unit is being
    // changed. Certain kinds of updates may cause the Unit to become unusable
    // while the update is in progress.
    UNIT_STATE_UPDATING = 3;

    // Unit is being deleted.
    UNIT_STATE_DEPROVISIONING = 4;

    // Unit has been provisioned and is ready for use
    UNIT_STATE_READY = 5;

    // Unit has error, when it is not ready and some error operation
    UNIT_STATE_ERROR = 6;
  }

  // ManagementMode describes who is responsible for the management of the unit.
  enum ManagementMode {
    MANAGEMENT_MODE_UNSPECIFIED = 0;

    // Unit's lifecycle is managed by the user.
    MANAGEMENT_MODE_USER = 1;

    // The system will decide when to deprovision and delete the unit.
    // User still can deprovision or delete the unit manually.
    MANAGEMENT_MODE_SYSTEM = 2;
  }

  enum SystemManagedState {
    SYSTEM_MANAGED_STATE_UNSPECIFIED = 0;

    // Unit has dependents attached.
    SYSTEM_MANAGED_STATE_ACTIVE = 1;

    // Unit has no dependencies attached, but attachment is allowed.
    SYSTEM_MANAGED_STATE_INACTIVE = 2;

    // Unit has no dependencies attached, and attachment is not allowed.
    SYSTEM_MANAGED_STATE_DECOMMISSIONED = 3;
  }

  // Identifier. The resource name (full URI of the resource) following the
  // standard naming scheme:
  //
  //   "projects/{project}/locations/{location}/units/{unit}"
  string name = 1 [(google.api.field_behavior) = IDENTIFIER];

  // Optional. Reference to the UnitKind this Unit belongs to. Immutable once
  // set.
  string unit_kind = 2 [
    (google.api.field_behavior) = OPTIONAL,
    (google.api.resource_reference) = {
      type: "saasservicemgmt.googleapis.com/UnitKind"
    }
  ];

  // Optional. Output only. The current Release object for this Unit.
  string release = 13 [
    (google.api.field_behavior) = OPTIONAL,
    (google.api.field_behavior) = OUTPUT_ONLY,
    (google.api.resource_reference) = {
      type: "saasservicemgmt.googleapis.com/Release"
    }
  ];

  // Optional. Reference to the Saas Tenant resource this unit belongs to. This
  // for example informs the maintenance policies to use for scheduling future
  // updates on a unit. (optional and immutable once created)
  string tenant = 4 [
    (google.api.field_behavior) = OPTIONAL,
    (google.api.resource_reference) = {
      type: "saasservicemgmt.googleapis.com/Tenant"
    }
  ];

  // Optional. Output only. List of concurrent UnitOperations that are operating
  // on this Unit.
  repeated string ongoing_operations = 5 [
    (google.api.field_behavior) = OPTIONAL,
    (google.api.field_behavior) = OUTPUT_ONLY,
    (google.api.resource_reference) = {
      type: "saasservicemgmt.googleapis.com/UnitOperation"
    }
  ];

  // Optional. Output only. List of pending (wait to be executed) UnitOperations
  // for this unit.
  repeated string pending_operations = 6 [
    (google.api.field_behavior) = OPTIONAL,
    (google.api.field_behavior) = OUTPUT_ONLY,
    (google.api.resource_reference) = {
      type: "saasservicemgmt.googleapis.com/UnitOperation"
    }
  ];

  // Optional. Output only. List of scheduled UnitOperations for this unit.
  repeated string scheduled_operations = 24 [
    (google.api.field_behavior) = OPTIONAL,
    (google.api.field_behavior) = OUTPUT_ONLY,
    (google.api.resource_reference) = {
      type: "saasservicemgmt.googleapis.com/UnitOperation"
    }
  ];

  // Optional. Output only. List of Units that depend on this unit. Unit can
  // only be deprovisioned if this list is empty. Maximum 1000.
  repeated UnitDependency dependents = 7 [
    (google.api.field_behavior) = OPTIONAL,
    (google.api.field_behavior) = OUTPUT_ONLY
  ];

  // Optional. Output only. Set of dependencies for this unit. Maximum 10.
  repeated UnitDependency dependencies = 8 [
    (google.api.field_behavior) = OPTIONAL,
    (google.api.field_behavior) = OUTPUT_ONLY
  ];

  // Optional. Output only. Indicates the current input variables deployed by
  // the unit
  repeated UnitVariable input_variables = 9 [
    (google.api.field_behavior) = OPTIONAL,
    (google.api.field_behavior) = OUTPUT_ONLY
  ];

  // Optional. Output only. Set of key/value pairs corresponding to output
  // variables from execution of actuation templates. The variables are declared
  // in actuation configs (e.g in helm chart or terraform) and the values are
  // fetched and returned by the actuation engine upon completion of execution.
  repeated UnitVariable output_variables = 10 [
    (google.api.field_behavior) = OPTIONAL,
    (google.api.field_behavior) = OUTPUT_ONLY
  ];

  // Optional. Captures requested directives for performing future maintenance
  // on the unit. This includes a request for the unit to skip maintenance for a
  // period of time and remain pinned to its current release as well as controls
  // for postponing maintenance scheduled in future.
  MaintenanceSettings maintenance = 14 [(google.api.field_behavior) = OPTIONAL];

  // Optional. Output only. Current lifecycle state of the resource (e.g. if
  // it's being created or ready to use).
  UnitState state = 16 [
    (google.api.field_behavior) = OPTIONAL,
    (google.api.field_behavior) = OUTPUT_ONLY
  ];

  // Optional. Output only. A set of conditions which indicate the various
  // conditions this resource can have.
  repeated UnitCondition conditions = 20 [
    (google.api.field_behavior) = OPTIONAL,
    (google.api.field_behavior) = OUTPUT_ONLY
  ];

  // Optional. Immutable. Indicates whether the Unit life cycle is controlled
  // by the user or by the system.
  // Immutable once created.
  ManagementMode management_mode = 22 [
    (google.api.field_behavior) = OPTIONAL,
    (google.api.field_behavior) = IMMUTABLE
  ];

  // Optional. Output only. Indicates the system managed state of the unit.
  SystemManagedState system_managed_state = 25 [
    (google.api.field_behavior) = OPTIONAL,
    (google.api.field_behavior) = OUTPUT_ONLY
  ];

  // Optional. Output only. If set, indicates the time when the system will
  // start removing the unit.
  google.protobuf.Timestamp system_cleanup_at = 26 [
    (google.api.field_behavior) = OPTIONAL,
    (google.api.field_behavior) = OUTPUT_ONLY
  ];

  // Optional. Reference to the AppHub Application this unit belongs to.
  // All resources deployed in this Unit will be associated with the specified
  // Application.
  string application = 29 [
    (google.api.field_behavior) = OPTIONAL,
    (google.api.resource_reference) = {
      type: "apphub.googleapis.com/Application"
    }
  ];

  // Optional. The labels on the resource, which can be used for categorization.
  // similar to Kubernetes resource labels.
  map<string, string> labels = 10401 [(google.api.field_behavior) = OPTIONAL];

  // Optional. Annotations is an unstructured key-value map stored with a
  // resource that may be set by external tools to store and retrieve arbitrary
  // metadata. They are not queryable and should be preserved when modifying
  // objects.
  //
  // More info: https://kubernetes.io/docs/user-guide/annotations
  map<string, string> annotations = 10402
      [(google.api.field_behavior) = OPTIONAL];

  // Output only. The unique identifier of the resource. UID is unique in the
  // time and space for this resource within the scope of the service. It is
  // typically generated by the server on successful creation of a resource
  // and must not be changed. UID is used to uniquely identify resources
  // with resource name reuses. This should be a UUID4.
  string uid = 10201 [
    (google.api.field_info).format = UUID4,
    (google.api.field_behavior) = OUTPUT_ONLY
  ];

  // Output only. An opaque value that uniquely identifies a version or
  // generation of a resource. It can be used to confirm that the client
  // and server agree on the ordering of a resource being written.
  string etag = 10202 [(google.api.field_behavior) = OUTPUT_ONLY];

  // Output only. The timestamp when the resource was created.
  google.protobuf.Timestamp create_time = 10303
      [(google.api.field_behavior) = OUTPUT_ONLY];

  // Output only. The timestamp when the resource was last updated. Any
  // change to the resource made by users must refresh this value.
  // Changes to a resource made by the service should refresh this value.
  google.protobuf.Timestamp update_time = 10304
      [(google.api.field_behavior) = OUTPUT_ONLY];

  // Output only. Indicates whether the resource location satisfies Zone
  // Separation constraints. This is false by default.
  bool satisfies_pzs = 10305 [(google.api.field_behavior) = OUTPUT_ONLY];

  // Output only. Reserved for future use.
  bool satisfies_pzi = 10306 [(google.api.field_behavior) = OUTPUT_ONLY];
}

// Set of dependencies for this unit. Maximum 10.
message UnitDependency {
  // Output only. Alias for the name of the dependency.
  string alias = 1 [(google.api.field_behavior) = OUTPUT_ONLY];

  // Output only. A reference to the Unit object.
  string unit = 2 [
    (google.api.field_behavior) = OUTPUT_ONLY,
    (google.api.resource_reference) = {
      type: "saasservicemgmt.googleapis.com/Unit"
    }
  ];
}

// UnitOperation encapsulates the intent of changing/interacting with the
// service component represented by the specific Unit. Multiple UnitOperations
// can be created (requested) and scheduled in the future, however only one will
// be allowed to execute at a time (that can change in the future for
// non-mutating operations).
//
// UnitOperations allow different actors interacting with the same
// unit to focus only on the change they have requested.
//
// This is a base object that contains the common fields in all unit operations.
// Next: 22
message UnitOperation {
  option (google.api.resource) = {
    type: "saasservicemgmt.googleapis.com/UnitOperation"
    pattern: "projects/{project}/locations/{location}/unitOperations/{unitOperation}"
    plural: "unitOperations"
    singular: "unitOperation"
  };

  // UnitOperationState describes the current state of the unit operation.
  enum UnitOperationState {
    UNIT_OPERATION_STATE_UNKNOWN = 0;

    // Unit operation is accepted but not ready to run.
    UNIT_OPERATION_STATE_PENDING = 1;

    // Unit operation is accepted and scheduled.
    UNIT_OPERATION_STATE_SCHEDULED = 2;

    // Unit operation is running.
    UNIT_OPERATION_STATE_RUNNING = 4;

    // Unit operation has completed successfully.
    UNIT_OPERATION_STATE_SUCCEEDED = 5;

    // Unit operation has failed.
    UNIT_OPERATION_STATE_FAILED = 6;

    // Unit operation was cancelled.
    UNIT_OPERATION_STATE_CANCELLED = 7;
  }

  oneof unit_operation_type {
    Provision provision = 8 [(google.api.field_behavior) = OPTIONAL];

    Upgrade upgrade = 9 [(google.api.field_behavior) = OPTIONAL];

    Deprovision deprovision = 10 [(google.api.field_behavior) = OPTIONAL];
  }

  // Identifier. The resource name (full URI of the resource) following the
  // standard naming scheme:
  //
  //  "projects/{project}/locations/{location}/unitOperations/{unitOperation}"
  string name = 1 [(google.api.field_behavior) = IDENTIFIER];

  // Required. Immutable. The Unit a given UnitOperation will act upon.
  string unit = 2 [
    (google.api.field_behavior) = REQUIRED,
    (google.api.field_behavior) = IMMUTABLE,
    (google.api.resource_reference) = {
      type: "saasservicemgmt.googleapis.com/Unit"
    }
  ];

  // Optional. Reference to parent resource: UnitOperation. If an operation
  // needs to create other operations as part of its workflow, each of the child
  // operations should have this field set to the parent. This can be used for
  // tracing. (Optional)
  string parent_unit_operation = 3 [
    (google.api.field_behavior) = OPTIONAL,
    (google.api.resource_reference) = {
      type: "saasservicemgmt.googleapis.com/UnitOperation"
    }
  ];

  // Optional. Specifies which rollout created this Unit Operation. This cannot
  // be modified and is used for filtering purposes only. If a dependent unit
  // and unit operation are created as part of another unit operation, they will
  // use the same rolloutId.
  string rollout = 4 [
    (google.api.field_behavior) = OPTIONAL,
    (google.api.resource_reference) = {
      type: "saasservicemgmt.googleapis.com/Rollout"
    }
  ];

  // Optional. When true, attempt to cancel the operation. Cancellation may fail
  // if the operation is already executing. (Optional)
  bool cancel = 5 [(google.api.field_behavior) = OPTIONAL];

  // Optional. Output only. UnitOperationState describes the current state of
  // the unit operation.
  UnitOperationState state = 6 [
    (google.api.field_behavior) = OPTIONAL,
    (google.api.field_behavior) = OUTPUT_ONLY
  ];

  // Optional. Output only. A set of conditions which indicate the various
  // conditions this resource can have.
  repeated UnitOperationCondition conditions = 7 [
    (google.api.field_behavior) = OPTIONAL,
    (google.api.field_behavior) = OUTPUT_ONLY
  ];

  // Optional. When to schedule this operation.
  Schedule schedule = 12 [(google.api.field_behavior) = OPTIONAL];

  // Optional. Output only. The engine state for on-going
  // deployment engine operation(s).
  // This field is opaque for external usage.
  string engine_state = 14 [
    (google.api.field_behavior) = OPTIONAL,
    (google.api.field_behavior) = OUTPUT_ONLY
  ];

  // Optional. Output only. UnitOperationErrorCategory describe the error
  // category.
  UnitOperationErrorCategory error_category = 15 [
    (google.api.field_behavior) = OPTIONAL,
    (google.api.field_behavior) = OUTPUT_ONLY
  ];

  // Optional. The labels on the resource, which can be used for categorization.
  // similar to Kubernetes resource labels.
  map<string, string> labels = 10401 [(google.api.field_behavior) = OPTIONAL];

  // Optional. Annotations is an unstructured key-value map stored with a
  // resource that may be set by external tools to store and retrieve arbitrary
  // metadata. They are not queryable and should be preserved when modifying
  // objects.
  //
  // More info: https://kubernetes.io/docs/user-guide/annotations
  map<string, string> annotations = 10402
      [(google.api.field_behavior) = OPTIONAL];

  // Output only. The unique identifier of the resource. UID is unique in the
  // time and space for this resource within the scope of the service. It is
  // typically generated by the server on successful creation of a resource
  // and must not be changed. UID is used to uniquely identify resources
  // with resource name reuses. This should be a UUID4.
  string uid = 10201 [
    (google.api.field_info).format = UUID4,
    (google.api.field_behavior) = OUTPUT_ONLY
  ];

  // Output only. An opaque value that uniquely identifies a version or
  // generation of a resource. It can be used to confirm that the client
  // and server agree on the ordering of a resource being written.
  string etag = 10202 [(google.api.field_behavior) = OUTPUT_ONLY];

  // Output only. The timestamp when the resource was created.
  google.protobuf.Timestamp create_time = 10303
      [(google.api.field_behavior) = OUTPUT_ONLY];

  // Output only. The timestamp when the resource was last updated. Any
  // change to the resource made by users must refresh this value.
  // Changes to a resource made by the service should refresh this value.
  google.protobuf.Timestamp update_time = 10304
      [(google.api.field_behavior) = OUTPUT_ONLY];

  // Output only. The timestamp when the resource was marked for deletion
  // (deletion is an asynchronous operation).
  google.protobuf.Timestamp delete_time = 10305
      [(google.api.field_behavior) = OUTPUT_ONLY];
}

// Provision is the unit operation that provision the underlying resources
// represented by a Unit. Can only execute if the Unit is not currently
// provisioned.
message Provision {
  // Optional. Reference to the Release object to use for the Unit. (optional).
  string release = 1 [
    (google.api.field_behavior) = OPTIONAL,
    (google.api.resource_reference) = {
      type: "saasservicemgmt.googleapis.com/Release"
    }
  ];

  // Optional. Set of input variables. Maximum 100. (optional)
  repeated UnitVariable input_variables = 3
      [(google.api.field_behavior) = OPTIONAL];
}

// Deprovision is the unit operation that deprovision the underlying
// resources represented by a Unit. Can only execute if the Unit is currently
// provisioned.
message Deprovision {}

// Upgrade is the unit operation that upgrades a provisioned unit, which may
// also include the underlying resources represented by a Unit. Can only execute
// if the Unit is currently provisioned.
message Upgrade {
  // Optional. Reference to the Release object to use for the Unit. (optional).
  string release = 1 [
    (google.api.field_behavior) = OPTIONAL,
    (google.api.resource_reference) = {
      type: "saasservicemgmt.googleapis.com/Release"
    }
  ];

  // Optional. Set of input variables. Maximum 100. (optional)
  repeated UnitVariable input_variables = 2
      [(google.api.field_behavior) = OPTIONAL];
}

// A time specification to schedule the maintenance.
message Schedule {
  // Optional. Start of operation. If not set, will be set to the start of the
  // next window. (optional)
  google.protobuf.Timestamp start_time = 1
      [(google.api.field_behavior) = OPTIONAL];
}

// A new version to be propagated and deployed to units. This includes pointers
// to packaged blueprints for actuation (e.g Helm or Terraform configuration
// packages) via artifact registry.
message Release {
  option (google.api.resource) = {
    type: "saasservicemgmt.googleapis.com/Release"
    pattern: "projects/{project}/locations/{location}/releases/{release}"
    plural: "releases"
    singular: "release"
  };

  // Set of requirements to be fulfilled on the Unit when using this Release.
  message ReleaseRequirements {
    // Optional. A list of releases from which a unit can be upgraded to this
    // one (optional). If left empty no constraints will be applied. When
    // provided, unit upgrade requests to this release will check and enforce
    // this constraint.
    repeated string upgradeable_from_releases = 1 [
      (google.api.field_behavior) = OPTIONAL,
      (google.api.resource_reference) = {
        type: "saasservicemgmt.googleapis.com/Release"
      }
    ];
  }

  // Identifier. The resource name (full URI of the resource) following the
  // standard naming scheme:
  //
  //   "projects/{project}/locations/{location}/releases/{release}"
  string name = 1 [(google.api.field_behavior) = IDENTIFIER];

  // Required. Immutable. Reference to the UnitKind this Release corresponds to
  // (required and immutable once created).
  string unit_kind = 2 [
    (google.api.field_behavior) = REQUIRED,
    (google.api.field_behavior) = IMMUTABLE,
    (google.api.resource_reference) = {
      type: "saasservicemgmt.googleapis.com/UnitKind"
    }
  ];

  // Optional. Blueprints are OCI Images that contain all of the artifacts
  // needed to provision a unit.
  Blueprint blueprint = 3 [(google.api.field_behavior) = OPTIONAL];

  // Optional. Set of requirements to be fulfilled on the Unit when using this
  // Release.
  ReleaseRequirements release_requirements = 4
      [(google.api.field_behavior) = OPTIONAL];

  // Optional. Output only. List of input variables declared on the blueprint
  // and can be present with their values on the unit spec
  repeated UnitVariable input_variables = 5 [
    (google.api.field_behavior) = OPTIONAL,
    (google.api.field_behavior) = OUTPUT_ONLY
  ];

  // Optional. Output only. List of output variables declared on the blueprint
  // and can be present with their values on the unit status
  repeated UnitVariable output_variables = 6 [
    (google.api.field_behavior) = OPTIONAL,
    (google.api.field_behavior) = OUTPUT_ONLY
  ];

  // Optional. Mapping of input variables to default values. Maximum 100
  repeated UnitVariable input_variable_defaults = 7
      [(google.api.field_behavior) = OPTIONAL];

  // Output only. Reference to component and revision in a composite
  // ApplicationTemplate.
  ComponentRef application_template_component = 9
      [(google.api.field_behavior) = OUTPUT_ONLY];

  // Optional. The labels on the resource, which can be used for categorization.
  // similar to Kubernetes resource labels.
  map<string, string> labels = 10401 [(google.api.field_behavior) = OPTIONAL];

  // Optional. Annotations is an unstructured key-value map stored with a
  // resource that may be set by external tools to store and retrieve arbitrary
  // metadata. They are not queryable and should be preserved when modifying
  // objects.
  //
  // More info: https://kubernetes.io/docs/user-guide/annotations
  map<string, string> annotations = 10402
      [(google.api.field_behavior) = OPTIONAL];

  // Output only. The unique identifier of the resource. UID is unique in the
  // time and space for this resource within the scope of the service. It is
  // typically generated by the server on successful creation of a resource
  // and must not be changed. UID is used to uniquely identify resources
  // with resource name reuses. This should be a UUID4.
  string uid = 10201 [
    (google.api.field_info).format = UUID4,
    (google.api.field_behavior) = OUTPUT_ONLY
  ];

  // Output only. An opaque value that uniquely identifies a version or
  // generation of a resource. It can be used to confirm that the client
  // and server agree on the ordering of a resource being written.
  string etag = 10202 [(google.api.field_behavior) = OUTPUT_ONLY];

  // Output only. The timestamp when the resource was created.
  google.protobuf.Timestamp create_time = 10303
      [(google.api.field_behavior) = OUTPUT_ONLY];

  // Output only. The timestamp when the resource was last updated. Any
  // change to the resource made by users must refresh this value.
  // Changes to a resource made by the service should refresh this value.
  google.protobuf.Timestamp update_time = 10304
      [(google.api.field_behavior) = OUTPUT_ONLY];
}

// Mapping of input variables to their respective output variable for
// depedenencies
message VariableMapping {
  oneof mapping_type {
    // Optional. Output variables which will get their values from dependencies
    FromMapping from = 2 [(google.api.field_behavior) = OPTIONAL];

    // Optional. Input variables whose values will be passed on to dependencies.
    ToMapping to = 3 [(google.api.field_behavior) = OPTIONAL];
  }

  // Required. name of the variable
  string variable = 1 [(google.api.field_behavior) = REQUIRED];
}

// Output variables whose values will be passed on to dependencies
message FromMapping {
  // Required. Alias of the dependency that the outputVariable will pass its
  // value to
  string dependency = 1 [(google.api.field_behavior) = REQUIRED];

  // Required. Name of the outputVariable on the dependency
  string output_variable = 2 [(google.api.field_behavior) = REQUIRED];
}

// Input variables whose values will be passed on to dependencies
message ToMapping {
  // Required. Alias of the dependency that the inputVariable will pass its
  // value to
  string dependency = 1 [(google.api.field_behavior) = REQUIRED];

  // Required. Name of the inputVariable on the dependency
  string input_variable = 2 [(google.api.field_behavior) = REQUIRED];

  // Optional. Tells App Lifecycle Manager if this mapping should be used during
  // lookup or not
  bool ignore_for_lookup = 3 [(google.api.field_behavior) = OPTIONAL];
}

// Dependency represent a single dependency with another unit kind by alias.
message Dependency {
  // Required. Immutable. The unit kind of the dependency.
  string unit_kind = 1 [
    (google.api.field_behavior) = REQUIRED,
    (google.api.field_behavior) = IMMUTABLE,
    (google.api.resource_reference) = {
      type: "saasservicemgmt.googleapis.com/UnitKind"
    }
  ];

  // Required. An alias for the dependency. Used for input variable mapping.
  string alias = 2 [(google.api.field_behavior) = REQUIRED];
}

// CompositeRef represents a reference to a composite resource.
// Next ID: 4
message CompositeRef {
  // Required. Reference to the ApplicationTemplate resource.
  string application_template = 1 [
    (google.api.field_behavior) = REQUIRED,
    (google.api.resource_reference) = {
      type: "designcenter.googleapis.com/ApplicationTemplate"
    }
  ];

  // Revision of the ApplicationTemplate to use.
  // Changes to revision will trigger manual resynchronization.
  // If empty, ApplicationTemplate will be ignored.
  string revision = 2 [(google.api.resource_reference) = {
    type: "designcenter.googleapis.com/ApplicationTemplateRevision"
  }];

  // Output only. Reference to on-going AppTemplate import and replication
  // operation (i.e. the operation_id for the long-running operation). This
  // field is opaque for external usage.
  string sync_operation = 3 [(google.api.field_behavior) = OUTPUT_ONLY];
}

// ComponentRef represents a reference to a component resource.
// Next ID: 4
message ComponentRef {
  // Reference to the Composite ApplicationTemplate.
  CompositeRef composite_ref = 1;

  // Name of the component in composite.Components
  string component = 2;

  // Revision of the component.
  // If the component does not have a revision, this field will be explicitly
  // set to the revision of the composite ApplicationTemplate.
  string revision = 3;
}

// AppParams contains the parameters for creating an AppHub Application.
message AppParams {
  // Scope of an application.
  message Scope {
    // Scope Type.
    enum Type {
      option allow_alias = true;

      // Unspecified type.
      TYPE_UNSPECIFIED = 0;

      // Regional type.
      TYPE_REGIONAL = 1;

      // Global type.
      TYPE_GLOBAL = 2;

      // Deprecated: Use TYPE_REGIONAL.
      REGIONAL = 1 [deprecated = true];

      // Deprecated: Use TYPE_GLOBAL.
      GLOBAL = 2 [deprecated = true];
    }

    // Required. Scope Type.
    Type type = 1 [(google.api.field_behavior) = REQUIRED];
  }

  // Grouping used to construct the name of the AppHub Application.
  // Multiple UnitKinds can specify the same group to use the same Application
  // across their respective units.
  // Corresponds to the app_boundary_id in the ADC composite
  // ApplicationTemplate. Defaults to UnitKind.name
  string group = 1;

  // Corresponds to the scope in the ADC composite ApplicationTemplate.
  // Defaults to TYPE_REGIONAL.
  Scope scope = 2;
}
