// 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.discoveryengine.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/discoveryengine/v1beta/license_config.proto";
import "google/protobuf/field_mask.proto";

option csharp_namespace = "Google.Cloud.DiscoveryEngine.V1Beta";
option go_package = "cloud.google.com/go/discoveryengine/apiv1beta/discoveryenginepb;discoveryenginepb";
option java_multiple_files = true;
option java_outer_classname = "LicenseConfigServiceProto";
option java_package = "com.google.cloud.discoveryengine.v1beta";
option objc_class_prefix = "DISCOVERYENGINE";
option php_namespace = "Google\\Cloud\\DiscoveryEngine\\V1beta";
option ruby_package = "Google::Cloud::DiscoveryEngine::V1beta";

// Service for managing license config related resources.
service LicenseConfigService {
  option (google.api.default_host) = "discoveryengine.googleapis.com";
  option (google.api.oauth_scopes) =
      "https://www.googleapis.com/auth/cloud-platform,"
      "https://www.googleapis.com/auth/discoveryengine.readwrite,"
      "https://www.googleapis.com/auth/discoveryengine.serving.readwrite";

  // Creates a
  // [LicenseConfig][google.cloud.discoveryengine.v1beta.LicenseConfig] This
  // method should only be used for creating NotebookLm licenses or Gemini
  // Enterprise free trial licenses.
  rpc CreateLicenseConfig(CreateLicenseConfigRequest) returns (LicenseConfig) {
    option (google.api.http) = {
      post: "/v1beta/{parent=projects/*/locations/*}/licenseConfigs"
      body: "license_config"
    };
    option (google.api.method_signature) =
        "parent,license_config,license_config_id";
  }

  // Updates the
  // [LicenseConfig][google.cloud.discoveryengine.v1beta.LicenseConfig]
  rpc UpdateLicenseConfig(UpdateLicenseConfigRequest) returns (LicenseConfig) {
    option (google.api.http) = {
      patch: "/v1beta/{license_config.name=projects/*/locations/*/licenseConfigs/*}"
      body: "license_config"
    };
    option (google.api.method_signature) = "license_config,update_mask";
  }

  // Gets a [LicenseConfig][google.cloud.discoveryengine.v1beta.LicenseConfig].
  rpc GetLicenseConfig(GetLicenseConfigRequest) returns (LicenseConfig) {
    option (google.api.http) = {
      get: "/v1beta/{name=projects/*/locations/*/licenseConfigs/*}"
    };
    option (google.api.method_signature) = "name";
  }

  // Lists all the
  // [LicenseConfig][google.cloud.discoveryengine.v1beta.LicenseConfig]s
  // associated with the project.
  rpc ListLicenseConfigs(ListLicenseConfigsRequest)
      returns (ListLicenseConfigsResponse) {
    option (google.api.http) = {
      get: "/v1beta/{parent=projects/*/locations/*}/licenseConfigs"
    };
    option (google.api.method_signature) = "parent";
  }

  // Distributes a
  // [LicenseConfig][google.cloud.discoveryengine.v1beta.LicenseConfig] from
  // billing account level to project level.
  rpc DistributeLicenseConfig(DistributeLicenseConfigRequest)
      returns (DistributeLicenseConfigResponse) {
    option (google.api.http) = {
      post: "/v1beta/{billing_account_license_config=billingAccounts/*/billingAccountLicenseConfigs/*}:distributeLicenseConfig"
      body: "*"
    };
    option (google.api.method_signature) =
        "billing_account_license_config,project_number,location,license_count,license_config_id";
  }

  // This method is called from the billing account side to retract the
  // [LicenseConfig][google.cloud.discoveryengine.v1beta.LicenseConfig] from the
  // given project back to the billing account.
  rpc RetractLicenseConfig(RetractLicenseConfigRequest)
      returns (RetractLicenseConfigResponse) {
    option (google.api.http) = {
      post: "/v1beta/{billing_account_license_config=billingAccounts/*/billingAccountLicenseConfigs/*}:retractLicenseConfig"
      body: "*"
    };
    option (google.api.method_signature) =
        "billing_account_license_config,license_config,full_retract,license_count";
  }
}

// Request message for
// [LicenseConfigService.CreateLicenseConfig][google.cloud.discoveryengine.v1beta.LicenseConfigService.CreateLicenseConfig]
// method.
message CreateLicenseConfigRequest {
  // Required. The parent resource name, such as
  // `projects/{project}/locations/{location}`.
  string parent = 1 [
    (google.api.field_behavior) = REQUIRED,
    (google.api.resource_reference) = {
      type: "discoveryengine.googleapis.com/Location"
    }
  ];

  // Required. The
  // [LicenseConfig][google.cloud.discoveryengine.v1beta.LicenseConfig] to
  // create.
  LicenseConfig license_config = 2 [(google.api.field_behavior) = REQUIRED];

  // Optional. The ID to use for the
  // [LicenseConfig][google.cloud.discoveryengine.v1beta.LicenseConfig], which
  // will become the final component of the
  // [LicenseConfig][google.cloud.discoveryengine.v1beta.LicenseConfig]'s
  // resource name. We are using the tier (product edition) name as the license
  // config id such as `search` or `search_and_assistant`.
  string license_config_id = 3 [(google.api.field_behavior) = OPTIONAL];
}

// Request message for
// [LicenseConfigService.UpdateLicenseConfig][google.cloud.discoveryengine.v1beta.LicenseConfigService.UpdateLicenseConfig]
// method.
message UpdateLicenseConfigRequest {
  // Required. The
  // [LicenseConfig][google.cloud.discoveryengine.v1beta.LicenseConfig] to
  // update.
  LicenseConfig license_config = 1 [(google.api.field_behavior) = REQUIRED];

  // Optional. Indicates which fields in the provided
  // [LicenseConfig][google.cloud.discoveryengine.v1beta.LicenseConfig] to
  // update.
  //
  // If an unsupported or unknown field is provided, an INVALID_ARGUMENT error
  // is returned.
  google.protobuf.FieldMask update_mask = 2
      [(google.api.field_behavior) = OPTIONAL];
}

// Request message for
// [LicenseConfigService.GetLicenseConfig][google.cloud.discoveryengine.v1beta.LicenseConfigService.GetLicenseConfig]
// method.
message GetLicenseConfigRequest {
  // Required. Full resource name of
  // [LicenseConfig][google.cloud.discoveryengine.v1beta.LicenseConfig], such as
  // `projects/{project}/locations/{location}/licenseConfigs/*`.
  //
  // If the caller does not have permission to access the
  // [LicenseConfig][google.cloud.discoveryengine.v1beta.LicenseConfig],
  // regardless of whether or not it exists, a PERMISSION_DENIED error is
  // returned.
  //
  // If the requested
  // [LicenseConfig][google.cloud.discoveryengine.v1beta.LicenseConfig] does not
  // exist, a NOT_FOUND error is returned.
  string name = 1 [
    (google.api.field_behavior) = REQUIRED,
    (google.api.resource_reference) = {
      type: "discoveryengine.googleapis.com/LicenseConfig"
    }
  ];
}

// Request message for
// [LicenseConfigService.ListLicenseConfigs][google.cloud.discoveryengine.v1beta.LicenseConfigService.ListLicenseConfigs]
// method.
message ListLicenseConfigsRequest {
  // Required. The parent branch resource name, such as
  // `projects/{project}/locations/{location}`.
  string parent = 1 [
    (google.api.field_behavior) = REQUIRED,
    (google.api.resource_reference) = {
      type: "discoveryengine.googleapis.com/Location"
    }
  ];

  // Optional. Not supported.
  int32 page_size = 2 [(google.api.field_behavior) = OPTIONAL];

  // Optional. Not supported.
  string page_token = 3 [(google.api.field_behavior) = OPTIONAL];

  // Optional. The filter to apply to the list results.
  //
  // The supported fields are:
  //
  //   * `subscription_tier`
  //   * `state`
  //
  // Examples:
  //
  //   * `subscription_tier=SUBSCRIPTION_TIER_SEARCH,state=ACTIVE` - Lists all
  //   active search license configs.
  //   * `state=ACTIVE` - Lists all active license configs.
  //
  // The filter string should be a comma-separated list of field=value pairs.
  string filter = 4 [(google.api.field_behavior) = OPTIONAL];
}

// Response message for
// [LicenseConfigService.ListLicenseConfigs][google.cloud.discoveryengine.v1beta.LicenseConfigService.ListLicenseConfigs]
// method.
message ListLicenseConfigsResponse {
  // All the customer's
  // [LicenseConfig][google.cloud.discoveryengine.v1beta.LicenseConfig]s.
  repeated LicenseConfig license_configs = 1;

  // Not supported.
  string next_page_token = 2;
}

// Request message for
// [LicenseConfigService.DistributeLicenseConfig][google.cloud.discoveryengine.v1beta.LicenseConfigService.DistributeLicenseConfig]
// method.
message DistributeLicenseConfigRequest {
  // Required. Full resource name of [BillingAccountLicenseConfig][].
  //
  // Format:
  // `billingAccounts/{billing_account}/billingAccountLicenseConfigs/{billing_account_license_config_id}`.
  string billing_account_license_config = 1 [
    (google.api.field_behavior) = REQUIRED,
    (google.api.resource_reference) = {
      type: "discoveryengine.googleapis.com/BillingAccountLicenseConfig"
    }
  ];

  // Required. The target GCP project number to distribute the license config
  // to.
  int64 project_number = 2 [(google.api.field_behavior) = REQUIRED];

  // Required. The target GCP project region to distribute the license config
  // to.
  string location = 3 [(google.api.field_behavior) = REQUIRED];

  // Required. The number of licenses to distribute.
  int64 license_count = 4 [(google.api.field_behavior) = REQUIRED];

  // Optional. Distribute seats to this license config instead of creating a new
  // one. If not specified, a new license config will be created from the
  // billing account license config.
  string license_config_id = 5 [(google.api.field_behavior) = OPTIONAL];
}

// Response message for
// [LicenseConfigService.DistributeLicenseConfig][google.cloud.discoveryengine.v1beta.LicenseConfigService.DistributeLicenseConfig]
// method.
message DistributeLicenseConfigResponse {
  // The updated or created LicenseConfig.
  LicenseConfig license_config = 1;
}

// Request message for
// [LicenseConfigService.RetractLicenseConfig][google.cloud.discoveryengine.v1beta.LicenseConfigService.RetractLicenseConfig]
// method.
message RetractLicenseConfigRequest {
  // Required. Full resource name of [BillingAccountLicenseConfig][].
  //
  // Format:
  // `billingAccounts/{billing_account}/billingAccountLicenseConfigs/{billing_account_license_config_id}`.
  string billing_account_license_config = 1 [
    (google.api.field_behavior) = REQUIRED,
    (google.api.resource_reference) = {
      type: "discoveryengine.googleapis.com/BillingAccountLicenseConfig"
    }
  ];

  // Required. Full resource name of
  // [LicenseConfig][google.cloud.discoveryengine.v1beta.LicenseConfig].
  //
  // Format:
  // `projects/{project}/locations/{location}/licenseConfigs/{license_config_id}`.
  string license_config = 2 [
    (google.api.field_behavior) = REQUIRED,
    (google.api.resource_reference) = {
      type: "discoveryengine.googleapis.com/LicenseConfig"
    }
  ];

  // Optional. If set to true, retract the entire license config. Otherwise,
  // retract the specified license count.
  bool full_retract = 3 [(google.api.field_behavior) = OPTIONAL];

  // Optional. The number of licenses to retract. Only used when full_retract is
  // false.
  int64 license_count = 4 [(google.api.field_behavior) = OPTIONAL];
}

// Response message for
// [LicenseConfigService.RetractLicenseConfig][google.cloud.discoveryengine.v1beta.LicenseConfigService.RetractLicenseConfig]
// method.
message RetractLicenseConfigResponse {
  // The updated LicenseConfig.
  LicenseConfig license_config = 1;
}
