// 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 Sessions
  import Foundation
  #if canImport(FoundationNetworking)
    import FoundationNetworking
  #endif
  import GoogleCloudLocation
  import GoogleCloudWkt
  import GoogleLongRunning
  import GoogleCloudGax

  /// A session represents an interaction with a user. You retrieve user input
  /// and pass it to the
  /// [DetectIntent][google.cloud.dialogflow.cx.v3.Sessions.DetectIntent] method to
  /// determine user intent and respond.
  ///
  /// [google.cloud.dialogflow.cx.v3.Sessions.DetectIntent]: <doc:Sessions/detectIntent(request:)>
  ///
  /// @Snippet(path: "SessionsQuickstart")
  public class SessionsClient: Clients.SessionsProtocol {
    let inner: any Clients.SessionsStub

    /// Creates a new `SessionsClient` instance.
    public init(_ options: GoogleCloudGax.ClientOptions = .init()) throws {
      var inner: any Clients.SessionsStub = try Clients.SessionsTransport(options)
      inner = Clients.SessionsRetry(inner, options: options)
      if let logger = options.logger {
        inner = Clients.SessionsLogging(inner, logger: logger)
      }
      self.inner = inner
    }

    /// Processes a natural language query and returns structured, actionable data
    /// as a result. This method is not idempotent, because it may cause session
    /// entity types to be updated, which in turn might affect results of future
    /// queries.
    ///
    /// Note: Always use agent versions for production traffic.
    /// See [Versions and
    /// environments](https://cloud.google.com/dialogflow/cx/docs/concept/version).
    ///
    /// @Snippet(path: "Sessions_DetectIntent")
    public func detectIntent(
      request: DetectIntentRequest, options: GoogleCloudGax.RequestOptions
    ) async throws -> GoogleCloudDialogflowCXV3.DetectIntentResponse {
      try await self.inner.detectIntent(request: request, options: options)
    }

    /// Processes a natural language query and returns structured, actionable data
    /// as a result through server-side streaming. Server-side streaming allows
    /// Dialogflow to send [partial
    /// responses](https://cloud.google.com/dialogflow/cx/docs/concept/fulfillment#partial-response)
    /// earlier in a single request.
    ///
    /// @Snippet(path: "Sessions_ServerStreamingDetectIntent")
    public func serverStreamingDetectIntent(
      request: DetectIntentRequest, options: GoogleCloudGax.RequestOptions
    ) async throws -> GoogleCloudDialogflowCXV3.DetectIntentResponse {
      try await self.inner.serverStreamingDetectIntent(request: request, options: options)
    }

    /// Returns preliminary intent match results, doesn't change the session
    /// status.
    ///
    /// @Snippet(path: "Sessions_MatchIntent")
    public func matchIntent(
      request: MatchIntentRequest, options: GoogleCloudGax.RequestOptions
    ) async throws -> GoogleCloudDialogflowCXV3.MatchIntentResponse {
      try await self.inner.matchIntent(request: request, options: options)
    }

    /// Fulfills a matched intent returned by
    /// [MatchIntent][google.cloud.dialogflow.cx.v3.Sessions.MatchIntent]. Must be
    /// called after
    /// [MatchIntent][google.cloud.dialogflow.cx.v3.Sessions.MatchIntent], with
    /// input from
    /// [MatchIntentResponse][google.cloud.dialogflow.cx.v3.MatchIntentResponse].
    /// Otherwise, the behavior is undefined.
    ///
    /// [google.cloud.dialogflow.cx.v3.MatchIntentResponse]: <doc:MatchIntentResponse>
    /// [google.cloud.dialogflow.cx.v3.Sessions.MatchIntent]: <doc:Sessions/matchIntent(request:)>
    ///
    /// @Snippet(path: "Sessions_FulfillIntent")
    public func fulfillIntent(
      request: FulfillIntentRequest, options: GoogleCloudGax.RequestOptions
    ) async throws -> GoogleCloudDialogflowCXV3.FulfillIntentResponse {
      try await self.inner.fulfillIntent(request: request, options: options)
    }

    /// Updates the feedback received from the user for a single turn of the bot
    /// response.
    ///
    /// @Snippet(path: "Sessions_SubmitAnswerFeedback")
    public func submitAnswerFeedback(
      request: SubmitAnswerFeedbackRequest, options: GoogleCloudGax.RequestOptions
    ) async throws -> GoogleCloudDialogflowCXV3.AnswerFeedback {
      try await self.inner.submitAnswerFeedback(request: request, options: options)
    }

    /// Lists information about the supported locations for this service.
    ///
    /// This method lists locations based on the resource scope provided in
    /// the [ListLocationsRequest.name][google.cloud.location.ListLocationsRequest.name] field: *
    /// **Global locations**: If `name` is empty, the method lists the
    /// public locations available to all projects. * **Project-specific
    /// locations**: If `name` follows the format
    /// `projects/{project}`, the method lists locations visible to that
    /// specific project. This includes public, private, or other
    /// project-specific locations enabled for the project.
    ///
    /// For gRPC and client library implementations, the resource name is
    /// passed as the `name` field. For direct service calls, the resource
    /// name is
    /// incorporated into the request path based on the specific service
    /// implementation and version.
    ///
    /// [google.cloud.location.ListLocationsRequest.name]: https://www.google.com/search?q=Swift+google.cloud.location+GoogleCloudLocation.ListLocationsRequest/name
    ///
    /// @Snippet(path: "Sessions_ListLocations")
    public func listLocations(
      request: GoogleCloudLocation.ListLocationsRequest, options: GoogleCloudGax.RequestOptions
    ) async throws -> GoogleCloudLocation.ListLocationsResponse {
      try await self.inner.listLocations(request: request, options: options)
    }

    /// Lists information about the supported locations for this service.
    ///
    /// This method lists locations based on the resource scope provided in
    /// the [ListLocationsRequest.name][google.cloud.location.ListLocationsRequest.name] field: *
    /// **Global locations**: If `name` is empty, the method lists the
    /// public locations available to all projects. * **Project-specific
    /// locations**: If `name` follows the format
    /// `projects/{project}`, the method lists locations visible to that
    /// specific project. This includes public, private, or other
    /// project-specific locations enabled for the project.
    ///
    /// For gRPC and client library implementations, the resource name is
    /// passed as the `name` field. For direct service calls, the resource
    /// name is
    /// incorporated into the request path based on the specific service
    /// implementation and version.
    ///
    /// [google.cloud.location.ListLocationsRequest.name]: https://www.google.com/search?q=Swift+google.cloud.location+GoogleCloudLocation.ListLocationsRequest/name
    ///
    /// @Snippet(path: "Sessions_ListLocations")
    public func listLocations(
      byItem: GoogleCloudLocation.ListLocationsRequest, options: GoogleCloudGax.RequestOptions
    ) throws -> any AsyncSequence<GoogleCloudLocation.Location, Swift.Error> {
      let listRpc = {
        (token: Swift.String) async throws -> GoogleCloudLocation.ListLocationsResponse in
        var request = byItem
        request.pageToken = token
        return try await self.listLocations(request: request, options: options)
      }
      return GoogleCloudGax.PaginatedResponseSequence(listRpc: listRpc)
    }

    /// Gets information about a location.
    ///
    /// @Snippet(path: "Sessions_GetLocation")
    public func getLocation(
      request: GoogleCloudLocation.GetLocationRequest, options: GoogleCloudGax.RequestOptions
    ) async throws -> GoogleCloudLocation.Location {
      try await self.inner.getLocation(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: "Sessions_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: "Sessions_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: "Sessions_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: "Sessions_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 `SessionsClient`.
    ///
    /// To mock `SessionsClient` change your functions to receive
    /// `some SessionsProtocol` or `any SessionsProtocol`
    /// and pass a mock implementation in your tests.
    public protocol SessionsProtocol {
      /// See `SessionsClient.detectIntent`.
      func detectIntent(request: DetectIntentRequest) async throws
        -> GoogleCloudDialogflowCXV3.DetectIntentResponse

      /// See `SessionsClient.serverStreamingDetectIntent`.
      func serverStreamingDetectIntent(request: DetectIntentRequest) async throws
        -> GoogleCloudDialogflowCXV3.DetectIntentResponse

      /// See `SessionsClient.matchIntent`.
      func matchIntent(request: MatchIntentRequest) async throws
        -> GoogleCloudDialogflowCXV3.MatchIntentResponse

      /// See `SessionsClient.fulfillIntent`.
      func fulfillIntent(request: FulfillIntentRequest) async throws
        -> GoogleCloudDialogflowCXV3.FulfillIntentResponse

      /// See `SessionsClient.submitAnswerFeedback`.
      func submitAnswerFeedback(request: SubmitAnswerFeedbackRequest) async throws
        -> GoogleCloudDialogflowCXV3.AnswerFeedback

      /// See `SessionsClient.listLocations`.
      func listLocations(request: GoogleCloudLocation.ListLocationsRequest) async throws
        -> GoogleCloudLocation.ListLocationsResponse

      /// See `SessionsClient.listLocations`.
      func listLocations(
        byItem: GoogleCloudLocation.ListLocationsRequest
      ) throws -> any AsyncSequence<GoogleCloudLocation.Location, Swift.Error>

      /// See `SessionsClient.getLocation`.
      func getLocation(request: GoogleCloudLocation.GetLocationRequest) async throws
        -> GoogleCloudLocation.Location

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

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

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

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

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

      /// See `SessionsClient.detectIntent`.
      func detectIntent(
        request: DetectIntentRequest, options: GoogleCloudGax.RequestOptions
      ) async throws -> GoogleCloudDialogflowCXV3.DetectIntentResponse

      /// See `SessionsClient.serverStreamingDetectIntent`.
      func serverStreamingDetectIntent(
        request: DetectIntentRequest, options: GoogleCloudGax.RequestOptions
      ) async throws -> GoogleCloudDialogflowCXV3.DetectIntentResponse

      /// See `SessionsClient.matchIntent`.
      func matchIntent(
        request: MatchIntentRequest, options: GoogleCloudGax.RequestOptions
      ) async throws -> GoogleCloudDialogflowCXV3.MatchIntentResponse

      /// See `SessionsClient.fulfillIntent`.
      func fulfillIntent(
        request: FulfillIntentRequest, options: GoogleCloudGax.RequestOptions
      ) async throws -> GoogleCloudDialogflowCXV3.FulfillIntentResponse

      /// See `SessionsClient.submitAnswerFeedback`.
      func submitAnswerFeedback(
        request: SubmitAnswerFeedbackRequest, options: GoogleCloudGax.RequestOptions
      ) async throws -> GoogleCloudDialogflowCXV3.AnswerFeedback

      /// See `SessionsClient.listLocations`.
      func listLocations(
        request: GoogleCloudLocation.ListLocationsRequest, options: GoogleCloudGax.RequestOptions
      ) async throws -> GoogleCloudLocation.ListLocationsResponse

      /// See `SessionsClient.listLocations`.
      func listLocations(
        byItem: GoogleCloudLocation.ListLocationsRequest, options: GoogleCloudGax.RequestOptions
      ) throws -> any AsyncSequence<GoogleCloudLocation.Location, Swift.Error>

      /// See `SessionsClient.getLocation`.
      func getLocation(
        request: GoogleCloudLocation.GetLocationRequest, options: GoogleCloudGax.RequestOptions
      ) async throws -> GoogleCloudLocation.Location

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

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

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

  // Default implementations
  extension Clients.SessionsProtocol {
    public func detectIntent(request: DetectIntentRequest) async throws
      -> GoogleCloudDialogflowCXV3.DetectIntentResponse
    {
      try await self.detectIntent(request: request, options: .init())
    }

    public func detectIntent(
      request: DetectIntentRequest, options: GoogleCloudGax.RequestOptions
    ) async throws -> GoogleCloudDialogflowCXV3.DetectIntentResponse {
      throw GoogleCloudGax.RequestError.unimplemented
    }

    public func serverStreamingDetectIntent(request: DetectIntentRequest) async throws
      -> GoogleCloudDialogflowCXV3.DetectIntentResponse
    {
      try await self.serverStreamingDetectIntent(request: request, options: .init())
    }

    public func serverStreamingDetectIntent(
      request: DetectIntentRequest, options: GoogleCloudGax.RequestOptions
    ) async throws -> GoogleCloudDialogflowCXV3.DetectIntentResponse {
      throw GoogleCloudGax.RequestError.unimplemented
    }

    public func matchIntent(request: MatchIntentRequest) async throws
      -> GoogleCloudDialogflowCXV3.MatchIntentResponse
    {
      try await self.matchIntent(request: request, options: .init())
    }

    public func matchIntent(
      request: MatchIntentRequest, options: GoogleCloudGax.RequestOptions
    ) async throws -> GoogleCloudDialogflowCXV3.MatchIntentResponse {
      throw GoogleCloudGax.RequestError.unimplemented
    }

    public func fulfillIntent(request: FulfillIntentRequest) async throws
      -> GoogleCloudDialogflowCXV3.FulfillIntentResponse
    {
      try await self.fulfillIntent(request: request, options: .init())
    }

    public func fulfillIntent(
      request: FulfillIntentRequest, options: GoogleCloudGax.RequestOptions
    ) async throws -> GoogleCloudDialogflowCXV3.FulfillIntentResponse {
      throw GoogleCloudGax.RequestError.unimplemented
    }

    public func submitAnswerFeedback(request: SubmitAnswerFeedbackRequest) async throws
      -> GoogleCloudDialogflowCXV3.AnswerFeedback
    {
      try await self.submitAnswerFeedback(request: request, options: .init())
    }

    public func submitAnswerFeedback(
      request: SubmitAnswerFeedbackRequest, options: GoogleCloudGax.RequestOptions
    ) async throws -> GoogleCloudDialogflowCXV3.AnswerFeedback {
      throw GoogleCloudGax.RequestError.unimplemented
    }

    public func listLocations(request: GoogleCloudLocation.ListLocationsRequest) async throws
      -> GoogleCloudLocation.ListLocationsResponse
    {
      try await self.listLocations(request: request, options: .init())
    }

    public func listLocations(
      request: GoogleCloudLocation.ListLocationsRequest, options: GoogleCloudGax.RequestOptions
    ) async throws -> GoogleCloudLocation.ListLocationsResponse {
      throw GoogleCloudGax.RequestError.unimplemented
    }

    public func listLocations(
      byItem: GoogleCloudLocation.ListLocationsRequest
    ) throws -> any AsyncSequence<GoogleCloudLocation.Location, Swift.Error> {
      try self.listLocations(byItem: byItem, options: .init())
    }

    public func listLocations(
      byItem: GoogleCloudLocation.ListLocationsRequest, options: GoogleCloudGax.RequestOptions
    ) throws -> any AsyncSequence<GoogleCloudLocation.Location, Swift.Error> {
      let listRpc = {
        (token: Swift.String) async throws -> GoogleCloudLocation.ListLocationsResponse in
        throw GoogleCloudGax.RequestError.unimplemented
      }
      return GoogleCloudGax.PaginatedResponseSequence(listRpc: listRpc)
    }

    public func getLocation(request: GoogleCloudLocation.GetLocationRequest) async throws
      -> GoogleCloudLocation.Location
    {
      try await self.getLocation(request: request, options: .init())
    }

    public func getLocation(
      request: GoogleCloudLocation.GetLocationRequest, options: GoogleCloudGax.RequestOptions
    ) async throws -> GoogleCloudLocation.Location {
      throw GoogleCloudGax.RequestError.unimplemented
    }

    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
