// Code generated by sidekick. DO NOT EDIT.
//
// 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
//
//     https://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.

#if SessionService
  import Foundation
  #if canImport(FoundationNetworking)
    import FoundationNetworking
  #endif
  import GoogleCloudWkt
  import GoogleLongRunning
  import GoogleCloudGax

  /// Service for managing Sessions and Session-related resources.
  ///
  /// @Snippet(path: "SessionServiceQuickstart")
  public class SessionServiceClient: Clients.SessionServiceProtocol {
    let inner: any Clients.SessionServiceStub

    /// Creates a new `SessionServiceClient` instance.
    public init(_ options: GoogleCloudGax.ClientOptions = .init()) throws {
      var inner: any Clients.SessionServiceStub = try Clients.SessionServiceTransport(options)
      inner = Clients.SessionServiceRetry(inner, options: options)
      if let logger = options.logger {
        inner = Clients.SessionServiceLogging(inner, logger: logger)
      }
      self.inner = inner
    }

    /// Creates a Session.
    ///
    /// If the [Session][google.cloud.discoveryengine.v1.Session] to create already
    /// exists, an ALREADY_EXISTS error is returned.
    ///
    /// [google.cloud.discoveryengine.v1.Session]: <doc:Session>
    ///
    /// @Snippet(path: "SessionService_CreateSession")
    public func createSession(
      request: CreateSessionRequest, options: GoogleCloudGax.RequestOptions
    ) async throws -> GoogleCloudDiscoveryEngineV1.Session {
      try await self.inner.createSession(request: request, options: options)
    }

    /// Deletes a Session.
    ///
    /// If the [Session][google.cloud.discoveryengine.v1.Session] to delete does
    /// not exist, a NOT_FOUND error is returned.
    ///
    /// [google.cloud.discoveryengine.v1.Session]: <doc:Session>
    ///
    /// @Snippet(path: "SessionService_DeleteSession")
    public func deleteSession(
      request: DeleteSessionRequest, options: GoogleCloudGax.RequestOptions
    ) async throws {
      try await self.inner.deleteSession(request: request, options: options)
    }

    /// Updates a Session.
    ///
    /// [Session][google.cloud.discoveryengine.v1.Session] action type cannot be
    /// changed. If the [Session][google.cloud.discoveryengine.v1.Session] to
    /// update does not exist, a NOT_FOUND error is returned.
    ///
    /// [google.cloud.discoveryengine.v1.Session]: <doc:Session>
    ///
    /// @Snippet(path: "SessionService_UpdateSession")
    public func updateSession(
      request: UpdateSessionRequest, options: GoogleCloudGax.RequestOptions
    ) async throws -> GoogleCloudDiscoveryEngineV1.Session {
      try await self.inner.updateSession(request: request, options: options)
    }

    /// Gets a Session.
    ///
    /// @Snippet(path: "SessionService_GetSession")
    public func getSession(
      request: GetSessionRequest, options: GoogleCloudGax.RequestOptions
    ) async throws -> GoogleCloudDiscoveryEngineV1.Session {
      try await self.inner.getSession(request: request, options: options)
    }

    /// Lists all Sessions by their parent
    /// [DataStore][google.cloud.discoveryengine.v1.DataStore].
    ///
    /// [google.cloud.discoveryengine.v1.DataStore]: <doc:DataStore>
    ///
    /// @Snippet(path: "SessionService_ListSessions")
    public func listSessions(
      request: ListSessionsRequest, options: GoogleCloudGax.RequestOptions
    ) async throws -> GoogleCloudDiscoveryEngineV1.ListSessionsResponse {
      try await self.inner.listSessions(request: request, options: options)
    }

    /// Lists all Sessions by their parent
    /// [DataStore][google.cloud.discoveryengine.v1.DataStore].
    ///
    /// [google.cloud.discoveryengine.v1.DataStore]: <doc:DataStore>
    ///
    /// @Snippet(path: "SessionService_ListSessions")
    public func listSessions(
      byItem: ListSessionsRequest, options: GoogleCloudGax.RequestOptions
    ) throws -> any AsyncSequence<Session, Swift.Error> {
      let listRpc = {
        (token: Swift.String) async throws -> GoogleCloudDiscoveryEngineV1.ListSessionsResponse in
        var request = byItem
        request.pageToken = token
        return try await self.listSessions(request: request, options: options)
      }
      return GoogleCloudGax.PaginatedResponseSequence(listRpc: listRpc)
    }

    /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
    ///
    /// [google.longrunning.Operations]: https://www.google.com/search?q=Swift+google.longrunning+Operations
    ///
    /// @Snippet(path: "SessionService_ListOperations")
    public func listOperations(
      request: GoogleLongRunning.ListOperationsRequest, options: GoogleCloudGax.RequestOptions
    ) async throws -> GoogleLongRunning.ListOperationsResponse {
      try await self.inner.listOperations(request: request, options: options)
    }

    /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
    ///
    /// [google.longrunning.Operations]: https://www.google.com/search?q=Swift+google.longrunning+Operations
    ///
    /// @Snippet(path: "SessionService_ListOperations")
    public func listOperations(
      byItem: GoogleLongRunning.ListOperationsRequest, options: GoogleCloudGax.RequestOptions
    ) throws -> any AsyncSequence<GoogleLongRunning.Operation, Swift.Error> {
      let listRpc = {
        (token: Swift.String) async throws -> GoogleLongRunning.ListOperationsResponse in
        var request = byItem
        request.pageToken = token
        return try await self.listOperations(request: request, options: options)
      }
      return GoogleCloudGax.PaginatedResponseSequence(listRpc: listRpc)
    }

    /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
    ///
    /// [google.longrunning.Operations]: https://www.google.com/search?q=Swift+google.longrunning+Operations
    ///
    /// @Snippet(path: "SessionService_GetOperation")
    func getOperation(
      request: GoogleLongRunning.GetOperationRequest, options: GoogleCloudGax.RequestOptions
    ) async throws -> GoogleLongRunning.Operation {
      try await self.inner.getOperation(request: request, options: options)
    }

    /// Provides the [Operations][google.longrunning.Operations] service functionality in this service.
    ///
    /// [google.longrunning.Operations]: https://www.google.com/search?q=Swift+google.longrunning+Operations
    ///
    /// @Snippet(path: "SessionService_CancelOperation")
    public func cancelOperation(
      request: GoogleLongRunning.CancelOperationRequest, options: GoogleCloudGax.RequestOptions
    ) async throws {
      try await self.inner.cancelOperation(request: request, options: options)
    }
  }

  extension Clients {
    /// A Swift protocol to mock `SessionServiceClient`.
    ///
    /// To mock `SessionServiceClient` change your functions to receive
    /// `some SessionServiceProtocol` or `any SessionServiceProtocol`
    /// and pass a mock implementation in your tests.
    public protocol SessionServiceProtocol {
      /// See `SessionServiceClient.createSession`.
      func createSession(request: CreateSessionRequest) async throws
        -> GoogleCloudDiscoveryEngineV1.Session

      /// See `SessionServiceClient.createSession`.
      func createSession(
        parent: Swift.String,
        session: Session?,
      ) async throws -> GoogleCloudDiscoveryEngineV1.Session

      /// See `SessionServiceClient.deleteSession`.
      func deleteSession(request: DeleteSessionRequest) async throws

      /// See `SessionServiceClient.deleteSession`.
      func deleteSession(
        name: Swift.String,
      ) async throws

      /// See `SessionServiceClient.updateSession`.
      func updateSession(request: UpdateSessionRequest) async throws
        -> GoogleCloudDiscoveryEngineV1.Session

      /// See `SessionServiceClient.updateSession`.
      func updateSession(
        session: Session?,
        updateMask: GoogleCloudWkt.FieldMask?,
      ) async throws -> GoogleCloudDiscoveryEngineV1.Session

      /// See `SessionServiceClient.getSession`.
      func getSession(request: GetSessionRequest) async throws
        -> GoogleCloudDiscoveryEngineV1.Session

      /// See `SessionServiceClient.getSession`.
      func getSession(
        name: Swift.String,
      ) async throws -> GoogleCloudDiscoveryEngineV1.Session

      /// See `SessionServiceClient.listSessions`.
      func listSessions(request: ListSessionsRequest) async throws
        -> GoogleCloudDiscoveryEngineV1.ListSessionsResponse

      /// See `SessionServiceClient.listSessions`.
      func listSessions(
        byItem: ListSessionsRequest
      ) throws -> any AsyncSequence<Session, Swift.Error>

      /// See `SessionServiceClient.listSessions`.
      func listSessions(
        parent: Swift.String,
      ) throws -> any AsyncSequence<Session, Swift.Error>

      /// See `SessionServiceClient.listOperations`.
      func listOperations(request: GoogleLongRunning.ListOperationsRequest) async throws
        -> GoogleLongRunning.ListOperationsResponse

      /// See `SessionServiceClient.listOperations`.
      func listOperations(
        byItem: GoogleLongRunning.ListOperationsRequest
      ) throws -> any AsyncSequence<GoogleLongRunning.Operation, Swift.Error>

      /// See `SessionServiceClient.listOperations`.
      func listOperations(
        name: Swift.String,
        filter: Swift.String,
      ) throws -> any AsyncSequence<GoogleLongRunning.Operation, Swift.Error>

      /// See `SessionServiceClient.cancelOperation`.
      func cancelOperation(request: GoogleLongRunning.CancelOperationRequest) async throws

      /// See `SessionServiceClient.cancelOperation`.
      func cancelOperation(
        name: Swift.String,
      ) async throws

      /// See `SessionServiceClient.createSession`.
      func createSession(
        request: CreateSessionRequest, options: GoogleCloudGax.RequestOptions
      ) async throws -> GoogleCloudDiscoveryEngineV1.Session

      /// See `SessionServiceClient.deleteSession`.
      func deleteSession(
        request: DeleteSessionRequest, options: GoogleCloudGax.RequestOptions
      ) async throws

      /// See `SessionServiceClient.updateSession`.
      func updateSession(
        request: UpdateSessionRequest, options: GoogleCloudGax.RequestOptions
      ) async throws -> GoogleCloudDiscoveryEngineV1.Session

      /// See `SessionServiceClient.getSession`.
      func getSession(
        request: GetSessionRequest, options: GoogleCloudGax.RequestOptions
      ) async throws -> GoogleCloudDiscoveryEngineV1.Session

      /// See `SessionServiceClient.listSessions`.
      func listSessions(
        request: ListSessionsRequest, options: GoogleCloudGax.RequestOptions
      ) async throws -> GoogleCloudDiscoveryEngineV1.ListSessionsResponse

      /// See `SessionServiceClient.listSessions`.
      func listSessions(
        byItem: ListSessionsRequest, options: GoogleCloudGax.RequestOptions
      ) throws -> any AsyncSequence<Session, Swift.Error>

      /// See `SessionServiceClient.listOperations`.
      func listOperations(
        request: GoogleLongRunning.ListOperationsRequest, options: GoogleCloudGax.RequestOptions
      ) async throws -> GoogleLongRunning.ListOperationsResponse

      /// See `SessionServiceClient.listOperations`.
      func listOperations(
        byItem: GoogleLongRunning.ListOperationsRequest, options: GoogleCloudGax.RequestOptions
      ) throws -> any AsyncSequence<GoogleLongRunning.Operation, Swift.Error>

      /// See `SessionServiceClient.cancelOperation`.
      func cancelOperation(
        request: GoogleLongRunning.CancelOperationRequest, options: GoogleCloudGax.RequestOptions
      ) async throws
    }
  }

  // Default implementations
  extension Clients.SessionServiceProtocol {
    public func createSession(request: CreateSessionRequest) async throws
      -> GoogleCloudDiscoveryEngineV1.Session
    {
      try await self.createSession(request: request, options: .init())
    }

    public func createSession(
      request: CreateSessionRequest, options: GoogleCloudGax.RequestOptions
    ) async throws -> GoogleCloudDiscoveryEngineV1.Session {
      throw GoogleCloudGax.RequestError.unimplemented
    }

    public func createSession(
      parent: Swift.String,
      session: Session?,
    ) async throws -> GoogleCloudDiscoveryEngineV1.Session {
      let request = CreateSessionRequest().with {
        $0.parent = parent
        $0.session = session
      }
      return try await self.createSession(request: request)
    }

    public func deleteSession(request: DeleteSessionRequest) async throws {
      try await self.deleteSession(request: request, options: .init())
    }

    public func deleteSession(
      request: DeleteSessionRequest, options: GoogleCloudGax.RequestOptions
    ) async throws {
      throw GoogleCloudGax.RequestError.unimplemented
    }

    public func deleteSession(
      name: Swift.String,
    ) async throws {
      let request = DeleteSessionRequest().with {
        $0.name = name
      }
      try await self.deleteSession(request: request)
    }

    public func updateSession(request: UpdateSessionRequest) async throws
      -> GoogleCloudDiscoveryEngineV1.Session
    {
      try await self.updateSession(request: request, options: .init())
    }

    public func updateSession(
      request: UpdateSessionRequest, options: GoogleCloudGax.RequestOptions
    ) async throws -> GoogleCloudDiscoveryEngineV1.Session {
      throw GoogleCloudGax.RequestError.unimplemented
    }

    public func updateSession(
      session: Session?,
      updateMask: GoogleCloudWkt.FieldMask?,
    ) async throws -> GoogleCloudDiscoveryEngineV1.Session {
      let request = UpdateSessionRequest().with {
        $0.session = session
        $0.updateMask = updateMask
      }
      return try await self.updateSession(request: request)
    }

    public func getSession(request: GetSessionRequest) async throws
      -> GoogleCloudDiscoveryEngineV1.Session
    {
      try await self.getSession(request: request, options: .init())
    }

    public func getSession(
      request: GetSessionRequest, options: GoogleCloudGax.RequestOptions
    ) async throws -> GoogleCloudDiscoveryEngineV1.Session {
      throw GoogleCloudGax.RequestError.unimplemented
    }

    public func getSession(
      name: Swift.String,
    ) async throws -> GoogleCloudDiscoveryEngineV1.Session {
      let request = GetSessionRequest().with {
        $0.name = name
      }
      return try await self.getSession(request: request)
    }

    public func listSessions(request: ListSessionsRequest) async throws
      -> GoogleCloudDiscoveryEngineV1.ListSessionsResponse
    {
      try await self.listSessions(request: request, options: .init())
    }

    public func listSessions(
      request: ListSessionsRequest, options: GoogleCloudGax.RequestOptions
    ) async throws -> GoogleCloudDiscoveryEngineV1.ListSessionsResponse {
      throw GoogleCloudGax.RequestError.unimplemented
    }

    public func listSessions(
      byItem: ListSessionsRequest
    ) throws -> any AsyncSequence<Session, Swift.Error> {
      try self.listSessions(byItem: byItem, options: .init())
    }

    public func listSessions(
      byItem: ListSessionsRequest, options: GoogleCloudGax.RequestOptions
    ) throws -> any AsyncSequence<Session, Swift.Error> {
      let listRpc = {
        (token: Swift.String) async throws -> GoogleCloudDiscoveryEngineV1.ListSessionsResponse in
        throw GoogleCloudGax.RequestError.unimplemented
      }
      return GoogleCloudGax.PaginatedResponseSequence(listRpc: listRpc)
    }

    public func listSessions(
      parent: Swift.String,
    ) throws -> any AsyncSequence<Session, Swift.Error> {
      let request = ListSessionsRequest().with {
        $0.parent = parent
      }
      return try self.listSessions(byItem: request)
    }

    public func listOperations(request: GoogleLongRunning.ListOperationsRequest) async throws
      -> GoogleLongRunning.ListOperationsResponse
    {
      try await self.listOperations(request: request, options: .init())
    }

    public func listOperations(
      request: GoogleLongRunning.ListOperationsRequest, options: GoogleCloudGax.RequestOptions
    ) async throws -> GoogleLongRunning.ListOperationsResponse {
      throw GoogleCloudGax.RequestError.unimplemented
    }

    public func listOperations(
      byItem: GoogleLongRunning.ListOperationsRequest
    ) throws -> any AsyncSequence<GoogleLongRunning.Operation, Swift.Error> {
      try self.listOperations(byItem: byItem, options: .init())
    }

    public func listOperations(
      byItem: GoogleLongRunning.ListOperationsRequest, options: GoogleCloudGax.RequestOptions
    ) throws -> any AsyncSequence<GoogleLongRunning.Operation, Swift.Error> {
      let listRpc = {
        (token: Swift.String) async throws -> GoogleLongRunning.ListOperationsResponse in
        throw GoogleCloudGax.RequestError.unimplemented
      }
      return GoogleCloudGax.PaginatedResponseSequence(listRpc: listRpc)
    }

    public func listOperations(
      name: Swift.String,
      filter: Swift.String,
    ) throws -> any AsyncSequence<GoogleLongRunning.Operation, Swift.Error> {
      let request = GoogleLongRunning.ListOperationsRequest().with {
        $0.name = name
        $0.filter = filter
      }
      return try self.listOperations(byItem: request)
    }

    public func getOperation(request: GoogleLongRunning.GetOperationRequest) async throws
      -> GoogleLongRunning.Operation
    {
      try await self.getOperation(request: request, options: .init())
    }

    public func getOperation(
      request: GoogleLongRunning.GetOperationRequest, options: GoogleCloudGax.RequestOptions
    ) async throws -> GoogleLongRunning.Operation {
      throw GoogleCloudGax.RequestError.unimplemented
    }

    public func getOperation(
      name: Swift.String,
    ) async throws -> GoogleLongRunning.Operation {
      let request = GoogleLongRunning.GetOperationRequest().with {
        $0.name = name
      }
      return try await self.getOperation(request: request)
    }

    public func cancelOperation(request: GoogleLongRunning.CancelOperationRequest) async throws {
      try await self.cancelOperation(request: request, options: .init())
    }

    public func cancelOperation(
      request: GoogleLongRunning.CancelOperationRequest, options: GoogleCloudGax.RequestOptions
    ) async throws {
      throw GoogleCloudGax.RequestError.unimplemented
    }

    public func cancelOperation(
      name: Swift.String,
    ) async throws {
      let request = GoogleLongRunning.CancelOperationRequest().with {
        $0.name = name
      }
      try await self.cancelOperation(request: request)
    }
  }
#endif
