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

  extension Clients {
    protocol PlaybooksStub {
      func createPlaybook(
        request: CreatePlaybookRequest, options: GoogleCloudGax.RequestOptions
      ) async throws -> GoogleCloudDialogflowCXV3.Playbook

      func deletePlaybook(
        request: DeletePlaybookRequest, options: GoogleCloudGax.RequestOptions
      ) async throws

      func listPlaybooks(
        request: ListPlaybooksRequest, options: GoogleCloudGax.RequestOptions
      ) async throws -> GoogleCloudDialogflowCXV3.ListPlaybooksResponse

      func getPlaybook(
        request: GetPlaybookRequest, options: GoogleCloudGax.RequestOptions
      ) async throws -> GoogleCloudDialogflowCXV3.Playbook

      func exportPlaybook(
        request: ExportPlaybookRequest, options: GoogleCloudGax.RequestOptions
      ) async throws -> GoogleLongRunning.Operation

      func importPlaybook(
        request: ImportPlaybookRequest, options: GoogleCloudGax.RequestOptions
      ) async throws -> GoogleLongRunning.Operation

      func updatePlaybook(
        request: UpdatePlaybookRequest, options: GoogleCloudGax.RequestOptions
      ) async throws -> GoogleCloudDialogflowCXV3.Playbook

      func createPlaybookVersion(
        request: CreatePlaybookVersionRequest, options: GoogleCloudGax.RequestOptions
      ) async throws -> GoogleCloudDialogflowCXV3.PlaybookVersion

      func getPlaybookVersion(
        request: GetPlaybookVersionRequest, options: GoogleCloudGax.RequestOptions
      ) async throws -> GoogleCloudDialogflowCXV3.PlaybookVersion

      func restorePlaybookVersion(
        request: RestorePlaybookVersionRequest, options: GoogleCloudGax.RequestOptions
      ) async throws -> GoogleCloudDialogflowCXV3.RestorePlaybookVersionResponse

      func listPlaybookVersions(
        request: ListPlaybookVersionsRequest, options: GoogleCloudGax.RequestOptions
      ) async throws -> GoogleCloudDialogflowCXV3.ListPlaybookVersionsResponse

      func deletePlaybookVersion(
        request: DeletePlaybookVersionRequest, options: GoogleCloudGax.RequestOptions
      ) async throws

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

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

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

      func getOperation(
        request: GoogleLongRunning.GetOperationRequest, options: GoogleCloudGax.RequestOptions
      ) async throws -> GoogleLongRunning.Operation

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

    class PlaybooksTransport: PlaybooksStub {
      let inner: GoogleCloudGax.HTTPClient

      public init(_ options: GoogleCloudGax.ClientOptions = .init()) throws {
        self.inner = try GoogleCloudGax.HTTPClient(
          from: options, withDefaultEndpoint: "https://dialogflow.googleapis.com")
      }

      public func createPlaybook(
        request: CreatePlaybookRequest, options: GoogleCloudGax.RequestOptions
      ) async throws -> GoogleCloudDialogflowCXV3.Playbook {
        let path = try { () throws -> Swift.String in
          guard let pathVariable0 = request.parent as Swift.String?, !pathVariable0.isEmpty else {
            throw GoogleCloudGax.RequestError.binding("'request.parent' is not set or is empty")
          }
          return "/v3/\(pathVariable0)/playbooks"
        }()
        let query = [
          URLQueryItem(name: "$alt", value: "json;enum-encoding=int")
        ]
        var req = try await self.inner.Request(path: path, query: query)
        req.httpMethod = "POST"
        req.setValue(Clients.clientHeader, forHTTPHeaderField: "X-Goog-Api-Client")
        if let body = request.playbook {
          req.setValue("application/json", forHTTPHeaderField: "Content-Type")
          req.httpBody = try JSONEncoder().encode(body)
        }
        let (data, _) = try await self.inner.rpc(for: req).get()
        return try GoogleCloudWkt._ProtoJSONDecoder().decode(
          GoogleCloudDialogflowCXV3.Playbook.self, from: data)
      }

      public func deletePlaybook(
        request: DeletePlaybookRequest, options: GoogleCloudGax.RequestOptions
      ) async throws {
        let path = try { () throws -> Swift.String in
          guard let pathVariable0 = request.name as Swift.String?, !pathVariable0.isEmpty else {
            throw GoogleCloudGax.RequestError.binding("'request.name' is not set or is empty")
          }
          return "/v3/\(pathVariable0)"
        }()
        let query = [
          URLQueryItem(name: "$alt", value: "json;enum-encoding=int")
        ]
        var req = try await self.inner.Request(path: path, query: query)
        req.httpMethod = "DELETE"
        req.setValue(Clients.clientHeader, forHTTPHeaderField: "X-Goog-Api-Client")
        _ = try await self.inner.rpc(for: req).get()
      }

      public func listPlaybooks(
        request: ListPlaybooksRequest, options: GoogleCloudGax.RequestOptions
      ) async throws -> GoogleCloudDialogflowCXV3.ListPlaybooksResponse {
        let path = try { () throws -> Swift.String in
          guard let pathVariable0 = request.parent as Swift.String?, !pathVariable0.isEmpty else {
            throw GoogleCloudGax.RequestError.binding("'request.parent' is not set or is empty")
          }
          return "/v3/\(pathVariable0)/playbooks"
        }()
        var query = [
          URLQueryItem(name: "$alt", value: "json;enum-encoding=int")
        ]
        let encoder = GoogleCloudGax.QueryParameterEncoder()
        query.append(contentsOf: try encoder.encode(request.pageSize, prefix: "pageSize"))
        query.append(contentsOf: try encoder.encode(request.pageToken, prefix: "pageToken"))
        var req = try await self.inner.Request(path: path, query: query)
        req.httpMethod = "GET"
        req.setValue(Clients.clientHeader, forHTTPHeaderField: "X-Goog-Api-Client")
        let (data, _) = try await self.inner.rpc(for: req).get()
        return try GoogleCloudWkt._ProtoJSONDecoder().decode(
          GoogleCloudDialogflowCXV3.ListPlaybooksResponse.self, from: data)
      }

      public func getPlaybook(
        request: GetPlaybookRequest, options: GoogleCloudGax.RequestOptions
      ) async throws -> GoogleCloudDialogflowCXV3.Playbook {
        let path = try { () throws -> Swift.String in
          guard let pathVariable0 = request.name as Swift.String?, !pathVariable0.isEmpty else {
            throw GoogleCloudGax.RequestError.binding("'request.name' is not set or is empty")
          }
          return "/v3/\(pathVariable0)"
        }()
        let query = [
          URLQueryItem(name: "$alt", value: "json;enum-encoding=int")
        ]
        var req = try await self.inner.Request(path: path, query: query)
        req.httpMethod = "GET"
        req.setValue(Clients.clientHeader, forHTTPHeaderField: "X-Goog-Api-Client")
        let (data, _) = try await self.inner.rpc(for: req).get()
        return try GoogleCloudWkt._ProtoJSONDecoder().decode(
          GoogleCloudDialogflowCXV3.Playbook.self, from: data)
      }

      public func exportPlaybook(
        request: ExportPlaybookRequest, options: GoogleCloudGax.RequestOptions
      ) async throws -> GoogleLongRunning.Operation {
        let path = try { () throws -> Swift.String in
          guard let pathVariable0 = request.name as Swift.String?, !pathVariable0.isEmpty else {
            throw GoogleCloudGax.RequestError.binding("'request.name' is not set or is empty")
          }
          return "/v3/\(pathVariable0):export"
        }()
        let query = [
          URLQueryItem(name: "$alt", value: "json;enum-encoding=int")
        ]
        var req = try await self.inner.Request(path: path, query: query)
        req.httpMethod = "POST"
        req.setValue(Clients.clientHeader, forHTTPHeaderField: "X-Goog-Api-Client")
        req.setValue("application/json", forHTTPHeaderField: "Content-Type")
        req.httpBody = try JSONEncoder().encode(request)
        let (data, _) = try await self.inner.rpc(for: req).get()
        return try GoogleCloudWkt._ProtoJSONDecoder().decode(
          GoogleLongRunning.Operation.self, from: data)
      }

      public func importPlaybook(
        request: ImportPlaybookRequest, options: GoogleCloudGax.RequestOptions
      ) async throws -> GoogleLongRunning.Operation {
        let path = try { () throws -> Swift.String in
          guard let pathVariable0 = request.parent as Swift.String?, !pathVariable0.isEmpty else {
            throw GoogleCloudGax.RequestError.binding("'request.parent' is not set or is empty")
          }
          return "/v3/\(pathVariable0)/playbooks:import"
        }()
        let query = [
          URLQueryItem(name: "$alt", value: "json;enum-encoding=int")
        ]
        var req = try await self.inner.Request(path: path, query: query)
        req.httpMethod = "POST"
        req.setValue(Clients.clientHeader, forHTTPHeaderField: "X-Goog-Api-Client")
        req.setValue("application/json", forHTTPHeaderField: "Content-Type")
        req.httpBody = try JSONEncoder().encode(request)
        let (data, _) = try await self.inner.rpc(for: req).get()
        return try GoogleCloudWkt._ProtoJSONDecoder().decode(
          GoogleLongRunning.Operation.self, from: data)
      }

      public func updatePlaybook(
        request: UpdatePlaybookRequest, options: GoogleCloudGax.RequestOptions
      ) async throws -> GoogleCloudDialogflowCXV3.Playbook {
        let path = try { () throws -> Swift.String in
          guard let pathVariable0 = request.playbook.map({ $0.name }), !pathVariable0.isEmpty else {
            throw GoogleCloudGax.RequestError.binding(
              "'request.playbook.name' is not set or is empty")
          }
          return "/v3/\(pathVariable0)"
        }()
        var query = [
          URLQueryItem(name: "$alt", value: "json;enum-encoding=int")
        ]
        let encoder = GoogleCloudGax.QueryParameterEncoder()
        query.append(contentsOf: try encoder.encode(request.updateMask, prefix: "updateMask"))
        var req = try await self.inner.Request(path: path, query: query)
        req.httpMethod = "PATCH"
        req.setValue(Clients.clientHeader, forHTTPHeaderField: "X-Goog-Api-Client")
        if let body = request.playbook {
          req.setValue("application/json", forHTTPHeaderField: "Content-Type")
          req.httpBody = try JSONEncoder().encode(body)
        }
        let (data, _) = try await self.inner.rpc(for: req).get()
        return try GoogleCloudWkt._ProtoJSONDecoder().decode(
          GoogleCloudDialogflowCXV3.Playbook.self, from: data)
      }

      public func createPlaybookVersion(
        request: CreatePlaybookVersionRequest, options: GoogleCloudGax.RequestOptions
      ) async throws -> GoogleCloudDialogflowCXV3.PlaybookVersion {
        let path = try { () throws -> Swift.String in
          guard let pathVariable0 = request.parent as Swift.String?, !pathVariable0.isEmpty else {
            throw GoogleCloudGax.RequestError.binding("'request.parent' is not set or is empty")
          }
          return "/v3/\(pathVariable0)/versions"
        }()
        let query = [
          URLQueryItem(name: "$alt", value: "json;enum-encoding=int")
        ]
        var req = try await self.inner.Request(path: path, query: query)
        req.httpMethod = "POST"
        req.setValue(Clients.clientHeader, forHTTPHeaderField: "X-Goog-Api-Client")
        if let body = request.playbookVersion {
          req.setValue("application/json", forHTTPHeaderField: "Content-Type")
          req.httpBody = try JSONEncoder().encode(body)
        }
        let (data, _) = try await self.inner.rpc(for: req).get()
        return try GoogleCloudWkt._ProtoJSONDecoder().decode(
          GoogleCloudDialogflowCXV3.PlaybookVersion.self, from: data)
      }

      public func getPlaybookVersion(
        request: GetPlaybookVersionRequest, options: GoogleCloudGax.RequestOptions
      ) async throws -> GoogleCloudDialogflowCXV3.PlaybookVersion {
        let path = try { () throws -> Swift.String in
          guard let pathVariable0 = request.name as Swift.String?, !pathVariable0.isEmpty else {
            throw GoogleCloudGax.RequestError.binding("'request.name' is not set or is empty")
          }
          return "/v3/\(pathVariable0)"
        }()
        let query = [
          URLQueryItem(name: "$alt", value: "json;enum-encoding=int")
        ]
        var req = try await self.inner.Request(path: path, query: query)
        req.httpMethod = "GET"
        req.setValue(Clients.clientHeader, forHTTPHeaderField: "X-Goog-Api-Client")
        let (data, _) = try await self.inner.rpc(for: req).get()
        return try GoogleCloudWkt._ProtoJSONDecoder().decode(
          GoogleCloudDialogflowCXV3.PlaybookVersion.self, from: data)
      }

      public func restorePlaybookVersion(
        request: RestorePlaybookVersionRequest, options: GoogleCloudGax.RequestOptions
      ) async throws -> GoogleCloudDialogflowCXV3.RestorePlaybookVersionResponse {
        let path = try { () throws -> Swift.String in
          guard let pathVariable0 = request.name as Swift.String?, !pathVariable0.isEmpty else {
            throw GoogleCloudGax.RequestError.binding("'request.name' is not set or is empty")
          }
          return "/v3/\(pathVariable0):restore"
        }()
        let query = [
          URLQueryItem(name: "$alt", value: "json;enum-encoding=int")
        ]
        var req = try await self.inner.Request(path: path, query: query)
        req.httpMethod = "POST"
        req.setValue(Clients.clientHeader, forHTTPHeaderField: "X-Goog-Api-Client")
        req.setValue("application/json", forHTTPHeaderField: "Content-Type")
        req.httpBody = try JSONEncoder().encode(request)
        let (data, _) = try await self.inner.rpc(for: req).get()
        return try GoogleCloudWkt._ProtoJSONDecoder().decode(
          GoogleCloudDialogflowCXV3.RestorePlaybookVersionResponse.self, from: data)
      }

      public func listPlaybookVersions(
        request: ListPlaybookVersionsRequest, options: GoogleCloudGax.RequestOptions
      ) async throws -> GoogleCloudDialogflowCXV3.ListPlaybookVersionsResponse {
        let path = try { () throws -> Swift.String in
          guard let pathVariable0 = request.parent as Swift.String?, !pathVariable0.isEmpty else {
            throw GoogleCloudGax.RequestError.binding("'request.parent' is not set or is empty")
          }
          return "/v3/\(pathVariable0)/versions"
        }()
        var query = [
          URLQueryItem(name: "$alt", value: "json;enum-encoding=int")
        ]
        let encoder = GoogleCloudGax.QueryParameterEncoder()
        query.append(contentsOf: try encoder.encode(request.pageSize, prefix: "pageSize"))
        query.append(contentsOf: try encoder.encode(request.pageToken, prefix: "pageToken"))
        var req = try await self.inner.Request(path: path, query: query)
        req.httpMethod = "GET"
        req.setValue(Clients.clientHeader, forHTTPHeaderField: "X-Goog-Api-Client")
        let (data, _) = try await self.inner.rpc(for: req).get()
        return try GoogleCloudWkt._ProtoJSONDecoder().decode(
          GoogleCloudDialogflowCXV3.ListPlaybookVersionsResponse.self, from: data)
      }

      public func deletePlaybookVersion(
        request: DeletePlaybookVersionRequest, options: GoogleCloudGax.RequestOptions
      ) async throws {
        let path = try { () throws -> Swift.String in
          guard let pathVariable0 = request.name as Swift.String?, !pathVariable0.isEmpty else {
            throw GoogleCloudGax.RequestError.binding("'request.name' is not set or is empty")
          }
          return "/v3/\(pathVariable0)"
        }()
        let query = [
          URLQueryItem(name: "$alt", value: "json;enum-encoding=int")
        ]
        var req = try await self.inner.Request(path: path, query: query)
        req.httpMethod = "DELETE"
        req.setValue(Clients.clientHeader, forHTTPHeaderField: "X-Goog-Api-Client")
        _ = try await self.inner.rpc(for: req).get()
      }

      public func listLocations(
        request: GoogleCloudLocation.ListLocationsRequest, options: GoogleCloudGax.RequestOptions
      ) async throws -> GoogleCloudLocation.ListLocationsResponse {
        let path = try { () throws -> Swift.String in
          guard let pathVariable0 = request.name as Swift.String?, !pathVariable0.isEmpty else {
            throw GoogleCloudGax.RequestError.binding("'request.name' is not set or is empty")
          }
          return "/v3/\(pathVariable0)/locations"
        }()
        var query = [
          URLQueryItem(name: "$alt", value: "json;enum-encoding=int")
        ]
        let encoder = GoogleCloudGax.QueryParameterEncoder()
        query.append(contentsOf: try encoder.encode(request.filter, prefix: "filter"))
        query.append(contentsOf: try encoder.encode(request.pageSize, prefix: "pageSize"))
        query.append(contentsOf: try encoder.encode(request.pageToken, prefix: "pageToken"))
        var req = try await self.inner.Request(path: path, query: query)
        req.httpMethod = "GET"
        req.setValue(Clients.clientHeader, forHTTPHeaderField: "X-Goog-Api-Client")
        let (data, _) = try await self.inner.rpc(for: req).get()
        return try GoogleCloudWkt._ProtoJSONDecoder().decode(
          GoogleCloudLocation.ListLocationsResponse.self, from: data)
      }

      public func getLocation(
        request: GoogleCloudLocation.GetLocationRequest, options: GoogleCloudGax.RequestOptions
      ) async throws -> GoogleCloudLocation.Location {
        let path = try { () throws -> Swift.String in
          guard let pathVariable0 = request.name as Swift.String?, !pathVariable0.isEmpty else {
            throw GoogleCloudGax.RequestError.binding("'request.name' is not set or is empty")
          }
          return "/v3/\(pathVariable0)"
        }()
        let query = [
          URLQueryItem(name: "$alt", value: "json;enum-encoding=int")
        ]
        var req = try await self.inner.Request(path: path, query: query)
        req.httpMethod = "GET"
        req.setValue(Clients.clientHeader, forHTTPHeaderField: "X-Goog-Api-Client")
        let (data, _) = try await self.inner.rpc(for: req).get()
        return try GoogleCloudWkt._ProtoJSONDecoder().decode(
          GoogleCloudLocation.Location.self, from: data)
      }

      public func listOperations(
        request: GoogleLongRunning.ListOperationsRequest, options: GoogleCloudGax.RequestOptions
      ) async throws -> GoogleLongRunning.ListOperationsResponse {
        let path = try { () throws -> Swift.String in
          guard let pathVariable0 = request.name as Swift.String?, !pathVariable0.isEmpty else {
            throw GoogleCloudGax.RequestError.binding("'request.name' is not set or is empty")
          }
          return "/v3/\(pathVariable0)/operations"
        }()
        var query = [
          URLQueryItem(name: "$alt", value: "json;enum-encoding=int")
        ]
        let encoder = GoogleCloudGax.QueryParameterEncoder()
        query.append(contentsOf: try encoder.encode(request.filter, prefix: "filter"))
        query.append(contentsOf: try encoder.encode(request.pageSize, prefix: "pageSize"))
        query.append(contentsOf: try encoder.encode(request.pageToken, prefix: "pageToken"))
        query.append(
          contentsOf: try encoder.encode(
            request.returnPartialSuccess, prefix: "returnPartialSuccess"))
        var req = try await self.inner.Request(path: path, query: query)
        req.httpMethod = "GET"
        req.setValue(Clients.clientHeader, forHTTPHeaderField: "X-Goog-Api-Client")
        let (data, _) = try await self.inner.rpc(for: req).get()
        return try GoogleCloudWkt._ProtoJSONDecoder().decode(
          GoogleLongRunning.ListOperationsResponse.self, from: data)
      }

      public func getOperation(
        request: GoogleLongRunning.GetOperationRequest, options: GoogleCloudGax.RequestOptions
      ) async throws -> GoogleLongRunning.Operation {
        let path = try { () throws -> Swift.String in
          guard let pathVariable0 = request.name as Swift.String?, !pathVariable0.isEmpty else {
            throw GoogleCloudGax.RequestError.binding("'request.name' is not set or is empty")
          }
          return "/v3/\(pathVariable0)"
        }()
        let query = [
          URLQueryItem(name: "$alt", value: "json;enum-encoding=int")
        ]
        var req = try await self.inner.Request(path: path, query: query)
        req.httpMethod = "GET"
        req.setValue(Clients.clientHeader, forHTTPHeaderField: "X-Goog-Api-Client")
        let (data, _) = try await self.inner.rpc(for: req).get()
        return try GoogleCloudWkt._ProtoJSONDecoder().decode(
          GoogleLongRunning.Operation.self, from: data)
      }

      public func cancelOperation(
        request: GoogleLongRunning.CancelOperationRequest, options: GoogleCloudGax.RequestOptions
      ) async throws {
        let path = try { () throws -> Swift.String in
          guard let pathVariable0 = request.name as Swift.String?, !pathVariable0.isEmpty else {
            throw GoogleCloudGax.RequestError.binding("'request.name' is not set or is empty")
          }
          return "/v3/\(pathVariable0):cancel"
        }()
        let query = [
          URLQueryItem(name: "$alt", value: "json;enum-encoding=int")
        ]
        var req = try await self.inner.Request(path: path, query: query)
        req.httpMethod = "POST"
        req.setValue(Clients.clientHeader, forHTTPHeaderField: "X-Goog-Api-Client")
        _ = try await self.inner.rpc(for: req).get()
      }
    }
  }
#endif
