// 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.aiplatform.v1beta1;

import "google/api/annotations.proto";
import "google/api/client.proto";
import "google/api/field_behavior.proto";
import "google/api/resource.proto";
import "google/cloud/aiplatform/v1beta1/operation.proto";
import "google/cloud/aiplatform/v1beta1/session.proto";
import "google/longrunning/operations.proto";
import "google/protobuf/empty.proto";
import "google/protobuf/field_mask.proto";

option csharp_namespace = "Google.Cloud.AIPlatform.V1Beta1";
option go_package = "cloud.google.com/go/aiplatform/apiv1beta1/aiplatformpb;aiplatformpb";
option java_multiple_files = true;
option java_outer_classname = "SessionServiceProto";
option java_package = "com.google.cloud.aiplatform.v1beta1";
option php_namespace = "Google\\Cloud\\AIPlatform\\V1beta1";
option ruby_package = "Google::Cloud::AIPlatform::V1beta1";

// The service that manages Vertex Session related resources.
service SessionService {
  option (google.api.default_host) = "aiplatform.googleapis.com";
  option (google.api.oauth_scopes) =
      "https://www.googleapis.com/auth/cloud-platform";

  // Creates a new [Session][google.cloud.aiplatform.v1beta1.Session].
  rpc CreateSession(CreateSessionRequest)
      returns (google.longrunning.Operation) {
    option (google.api.http) = {
      post: "/v1beta1/{parent=projects/*/locations/*/reasoningEngines/*}/sessions"
      body: "session"
    };
    option (google.api.method_signature) = "parent,session";
    option (google.longrunning.operation_info) = {
      response_type: "Session"
      metadata_type: "CreateSessionOperationMetadata"
    };
  }

  // Gets details of the specific
  // [Session][google.cloud.aiplatform.v1beta1.Session].
  rpc GetSession(GetSessionRequest) returns (Session) {
    option (google.api.http) = {
      get: "/v1beta1/{name=projects/*/locations/*/reasoningEngines/*/sessions/*}"
    };
    option (google.api.method_signature) = "name";
  }

  // Lists [Sessions][google.cloud.aiplatform.v1beta1.Session] in a given
  // reasoning engine.
  rpc ListSessions(ListSessionsRequest) returns (ListSessionsResponse) {
    option (google.api.http) = {
      get: "/v1beta1/{parent=projects/*/locations/*/reasoningEngines/*}/sessions"
    };
    option (google.api.method_signature) = "parent";
  }

  // Updates the specific [Session][google.cloud.aiplatform.v1beta1.Session].
  rpc UpdateSession(UpdateSessionRequest) returns (Session) {
    option (google.api.http) = {
      patch: "/v1beta1/{session.name=projects/*/locations/*/reasoningEngines/*/sessions/*}"
      body: "session"
    };
    option (google.api.method_signature) = "session,update_mask";
  }

  // Deletes details of the specific
  // [Session][google.cloud.aiplatform.v1beta1.Session].
  rpc DeleteSession(DeleteSessionRequest)
      returns (google.longrunning.Operation) {
    option (google.api.http) = {
      delete: "/v1beta1/{name=projects/*/locations/*/reasoningEngines/*/sessions/*}"
    };
    option (google.api.method_signature) = "name";
    option (google.longrunning.operation_info) = {
      response_type: "google.protobuf.Empty"
      metadata_type: "DeleteOperationMetadata"
    };
  }

  // Lists [Events][google.cloud.aiplatform.v1beta1.Event] in a given session.
  rpc ListEvents(ListEventsRequest) returns (ListEventsResponse) {
    option (google.api.http) = {
      get: "/v1beta1/{parent=projects/*/locations/*/reasoningEngines/*/sessions/*}/events"
    };
    option (google.api.method_signature) = "parent";
  }

  // Appends an event to a given session.
  rpc AppendEvent(AppendEventRequest) returns (AppendEventResponse) {
    option (google.api.http) = {
      post: "/v1beta1/{name=projects/*/locations/*/reasoningEngines/*/sessions/*}:appendEvent"
      body: "event"
    };
    option (google.api.method_signature) = "name,event";
  }
}

// Request message for
// [SessionService.CreateSession][google.cloud.aiplatform.v1beta1.SessionService.CreateSession].
message CreateSessionRequest {
  // Required. The resource name of the location to create the session in.
  // Format:
  // `projects/{project}/locations/{location}/reasoningEngines/{reasoning_engine}`
  string parent = 1 [
    (google.api.field_behavior) = REQUIRED,
    (google.api.resource_reference) = {
      child_type: "aiplatform.googleapis.com/Session"
    }
  ];

  // Required. The session to create.
  Session session = 2 [(google.api.field_behavior) = REQUIRED];
}

// Metadata associated with the
// [SessionService.CreateSession][google.cloud.aiplatform.v1beta1.SessionService.CreateSession]
// operation.
message CreateSessionOperationMetadata {
  // The common part of the operation metadata.
  GenericOperationMetadata generic_metadata = 1;
}

// Request message for
// [SessionService.GetSession][google.cloud.aiplatform.v1beta1.SessionService.GetSession].
message GetSessionRequest {
  // Required. The resource name of the session.
  // Format:
  // `projects/{project}/locations/{location}/reasoningEngines/{reasoning_engine}/sessions/{session}`
  string name = 1 [
    (google.api.field_behavior) = REQUIRED,
    (google.api.resource_reference) = {
      type: "aiplatform.googleapis.com/Session"
    }
  ];
}

// Request message for
// [SessionService.ListSessions][google.cloud.aiplatform.v1beta1.SessionService.ListSessions].
message ListSessionsRequest {
  // Required. The resource name of the location to list sessions from.
  // Format:
  // `projects/{project}/locations/{location}/reasoningEngines/{reasoning_engine}`
  string parent = 1 [
    (google.api.field_behavior) = REQUIRED,
    (google.api.resource_reference) = {
      child_type: "aiplatform.googleapis.com/Session"
    }
  ];

  // Optional. The maximum number of sessions to return. The service may return
  // fewer than this value. If unspecified, at most 100 sessions will be
  // returned.
  int32 page_size = 2 [(google.api.field_behavior) = OPTIONAL];

  // Optional. The
  // [next_page_token][google.cloud.aiplatform.v1beta1.ListSessionsResponse.next_page_token]
  // value returned from a previous list
  // [SessionService.ListSessions][google.cloud.aiplatform.v1beta1.SessionService.ListSessions]
  // call.
  string page_token = 3 [(google.api.field_behavior) = OPTIONAL];

  // Optional. The standard list filter.
  // Supported fields:
  //    * `display_name`
  //
  // Example: `display_name=abc`.
  string filter = 4 [(google.api.field_behavior) = OPTIONAL];

  // Optional. A comma-separated list of fields to order by, sorted in ascending
  // order. Use "desc" after a field name for descending. Supported fields:
  //   * `create_time`
  //   * `update_time`
  //
  // Example: `create_time desc`.
  string order_by = 5 [(google.api.field_behavior) = OPTIONAL];
}

// Response message for
// [SessionService.ListSessions][google.cloud.aiplatform.v1beta1.SessionService.ListSessions].
message ListSessionsResponse {
  // A list of sessions matching the request.
  repeated Session sessions = 1;

  // A token, which can be sent as
  // [ListSessionsRequest.page_token][google.cloud.aiplatform.v1beta1.ListSessionsRequest.page_token]
  // to retrieve the next page. Absence of this field indicates there are no
  // subsequent pages.
  string next_page_token = 2;
}

// Request message for
// [SessionService.UpdateSession][google.cloud.aiplatform.v1beta1.SessionService.UpdateSession].
message UpdateSessionRequest {
  // Required. The session to update.
  // Format:
  // `projects/{project}/locations/{location}/reasoningEngines/{reasoning_engine}/sessions/{session}`
  Session session = 1 [(google.api.field_behavior) = REQUIRED];

  // Optional. Field mask is used to control which fields get updated. If the
  // mask is not present, all fields will be updated.
  google.protobuf.FieldMask update_mask = 2
      [(google.api.field_behavior) = OPTIONAL];
}

// Request message for
// [SessionService.DeleteSession][google.cloud.aiplatform.v1beta1.SessionService.DeleteSession].
message DeleteSessionRequest {
  // Required. The resource name of the session.
  // Format:
  // `projects/{project}/locations/{location}/reasoningEngines/{reasoning_engine}/sessions/{session}`
  string name = 1 [
    (google.api.field_behavior) = REQUIRED,
    (google.api.resource_reference) = {
      type: "aiplatform.googleapis.com/Session"
    }
  ];
}

// Request message for
// [SessionService.ListEvents][google.cloud.aiplatform.v1beta1.SessionService.ListEvents].
message ListEventsRequest {
  // Required. The resource name of the session to list events from.
  // Format:
  // `projects/{project}/locations/{location}/reasoningEngines/{reasoning_engine}/sessions/{session}`
  string parent = 1 [
    (google.api.field_behavior) = REQUIRED,
    (google.api.resource_reference) = {
      child_type: "aiplatform.googleapis.com/SessionEvent"
    }
  ];

  // Optional. The maximum number of events to return. The service may return
  // fewer than this value. If unspecified, at most 100 events will be returned.
  // These events are ordered by timestamp in ascending order.
  int32 page_size = 2 [(google.api.field_behavior) = OPTIONAL];

  // Optional. The
  // [next_page_token][google.cloud.aiplatform.v1beta1.ListEventsResponse.next_page_token]
  // value returned from a previous list
  // [SessionService.ListEvents][google.cloud.aiplatform.v1beta1.SessionService.ListEvents]
  // call.
  string page_token = 3 [(google.api.field_behavior) = OPTIONAL];
}

// Response message for
// [SessionService.ListEvents][google.cloud.aiplatform.v1beta1.SessionService.ListEvents].
message ListEventsResponse {
  // A list of events matching the request. Ordered by timestamp in ascending
  // order.
  repeated SessionEvent session_events = 1;

  // A token, which can be sent as
  // [ListEventsRequest.page_token][google.cloud.aiplatform.v1beta1.ListEventsRequest.page_token]
  // to retrieve the next page. Absence of this field indicates there are no
  // subsequent pages.
  string next_page_token = 2;
}

// Request message for
// [SessionService.AppendEvent][google.cloud.aiplatform.v1beta1.SessionService.AppendEvent].
message AppendEventRequest {
  // Required. The resource name of the session to append event to.
  // Format:
  // `projects/{project}/locations/{location}/reasoningEngines/{reasoning_engine}/sessions/{session}`
  string name = 1 [
    (google.api.field_behavior) = REQUIRED,
    (google.api.resource_reference) = {
      child_type: "aiplatform.googleapis.com/SessionEvent"
    }
  ];

  // Required. The event to append to the session.
  SessionEvent event = 2 [(google.api.field_behavior) = REQUIRED];
}

// Response message for
// [SessionService.AppendEvent][google.cloud.aiplatform.v1beta1.SessionService.AppendEvent].
message AppendEventResponse {}
