// 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.

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

extension Clients {
  protocol EkmServiceStub {
    func listEkmConnections(
      request: ListEkmConnectionsRequest, options: GoogleCloudGax.RequestOptions
    ) async throws -> GoogleCloudKMSV1.ListEkmConnectionsResponse

    func getEkmConnection(
      request: GetEkmConnectionRequest, options: GoogleCloudGax.RequestOptions
    ) async throws -> GoogleCloudKMSV1.EkmConnection

    func createEkmConnection(
      request: CreateEkmConnectionRequest, options: GoogleCloudGax.RequestOptions
    ) async throws -> GoogleCloudKMSV1.EkmConnection

    func updateEkmConnection(
      request: UpdateEkmConnectionRequest, options: GoogleCloudGax.RequestOptions
    ) async throws -> GoogleCloudKMSV1.EkmConnection

    func getEkmConfig(
      request: GetEkmConfigRequest, options: GoogleCloudGax.RequestOptions
    ) async throws -> GoogleCloudKMSV1.EkmConfig

    func updateEkmConfig(
      request: UpdateEkmConfigRequest, options: GoogleCloudGax.RequestOptions
    ) async throws -> GoogleCloudKMSV1.EkmConfig

    func verifyConnectivity(
      request: VerifyConnectivityRequest, options: GoogleCloudGax.RequestOptions
    ) async throws -> GoogleCloudKMSV1.VerifyConnectivityResponse

    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 setIamPolicy(
      request: GoogleIAMV1.SetIamPolicyRequest, options: GoogleCloudGax.RequestOptions
    ) async throws -> GoogleIAMV1.Policy

    func getIamPolicy(
      request: GoogleIAMV1.GetIamPolicyRequest, options: GoogleCloudGax.RequestOptions
    ) async throws -> GoogleIAMV1.Policy

    func testIamPermissions(
      request: GoogleIAMV1.TestIamPermissionsRequest, options: GoogleCloudGax.RequestOptions
    ) async throws -> GoogleIAMV1.TestIamPermissionsResponse

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

  class EkmServiceTransport: EkmServiceStub {
    let inner: GoogleCloudGax.HTTPClient

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

    public func listEkmConnections(
      request: ListEkmConnectionsRequest, options: GoogleCloudGax.RequestOptions
    ) async throws -> GoogleCloudKMSV1.ListEkmConnectionsResponse {
      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 "/v1/\(pathVariable0)/ekmConnections"
      }()
      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"))
      query.append(contentsOf: try encoder.encode(request.filter, prefix: "filter"))
      query.append(contentsOf: try encoder.encode(request.orderBy, prefix: "orderBy"))
      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(
        GoogleCloudKMSV1.ListEkmConnectionsResponse.self, from: data)
    }

    public func getEkmConnection(
      request: GetEkmConnectionRequest, options: GoogleCloudGax.RequestOptions
    ) async throws -> GoogleCloudKMSV1.EkmConnection {
      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 "/v1/\(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(
        GoogleCloudKMSV1.EkmConnection.self, from: data)
    }

    public func createEkmConnection(
      request: CreateEkmConnectionRequest, options: GoogleCloudGax.RequestOptions
    ) async throws -> GoogleCloudKMSV1.EkmConnection {
      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 "/v1/\(pathVariable0)/ekmConnections"
      }()
      var query = [
        URLQueryItem(name: "$alt", value: "json;enum-encoding=int")
      ]
      let encoder = GoogleCloudGax.QueryParameterEncoder()
      query.append(
        contentsOf: try encoder.encode(request.ekmConnectionId, prefix: "ekmConnectionId"))
      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.ekmConnection {
        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(
        GoogleCloudKMSV1.EkmConnection.self, from: data)
    }

    public func updateEkmConnection(
      request: UpdateEkmConnectionRequest, options: GoogleCloudGax.RequestOptions
    ) async throws -> GoogleCloudKMSV1.EkmConnection {
      let path = try { () throws -> Swift.String in
        guard let pathVariable0 = request.ekmConnection.map({ $0.name }), !pathVariable0.isEmpty
        else {
          throw GoogleCloudGax.RequestError.binding(
            "'request.ekm_connection.name' is not set or is empty")
        }
        return "/v1/\(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.ekmConnection {
        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(
        GoogleCloudKMSV1.EkmConnection.self, from: data)
    }

    public func getEkmConfig(
      request: GetEkmConfigRequest, options: GoogleCloudGax.RequestOptions
    ) async throws -> GoogleCloudKMSV1.EkmConfig {
      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 "/v1/\(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(
        GoogleCloudKMSV1.EkmConfig.self, from: data)
    }

    public func updateEkmConfig(
      request: UpdateEkmConfigRequest, options: GoogleCloudGax.RequestOptions
    ) async throws -> GoogleCloudKMSV1.EkmConfig {
      let path = try { () throws -> Swift.String in
        guard let pathVariable0 = request.ekmConfig.map({ $0.name }), !pathVariable0.isEmpty else {
          throw GoogleCloudGax.RequestError.binding(
            "'request.ekm_config.name' is not set or is empty")
        }
        return "/v1/\(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.ekmConfig {
        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(
        GoogleCloudKMSV1.EkmConfig.self, from: data)
    }

    public func verifyConnectivity(
      request: VerifyConnectivityRequest, options: GoogleCloudGax.RequestOptions
    ) async throws -> GoogleCloudKMSV1.VerifyConnectivityResponse {
      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 "/v1/\(pathVariable0):verifyConnectivity"
      }()
      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(
        GoogleCloudKMSV1.VerifyConnectivityResponse.self, from: data)
    }

    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 "/v1/\(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 "/v1/\(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 setIamPolicy(
      request: GoogleIAMV1.SetIamPolicyRequest, options: GoogleCloudGax.RequestOptions
    ) async throws -> GoogleIAMV1.Policy {
      let path = try { () throws -> Swift.String in
        guard let pathVariable0 = request.resource as Swift.String?, !pathVariable0.isEmpty else {
          throw GoogleCloudGax.RequestError.binding("'request.resource' is not set or is empty")
        }
        return "/v1/\(pathVariable0):setIamPolicy"
      }()
      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(
        GoogleIAMV1.Policy.self, from: data)
    }

    public func getIamPolicy(
      request: GoogleIAMV1.GetIamPolicyRequest, options: GoogleCloudGax.RequestOptions
    ) async throws -> GoogleIAMV1.Policy {
      let path = try { () throws -> Swift.String in
        guard let pathVariable0 = request.resource as Swift.String?, !pathVariable0.isEmpty else {
          throw GoogleCloudGax.RequestError.binding("'request.resource' is not set or is empty")
        }
        return "/v1/\(pathVariable0):getIamPolicy"
      }()
      var query = [
        URLQueryItem(name: "$alt", value: "json;enum-encoding=int")
      ]
      let encoder = GoogleCloudGax.QueryParameterEncoder()
      query.append(contentsOf: try encoder.encode(request.options, prefix: "options"))
      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(
        GoogleIAMV1.Policy.self, from: data)
    }

    public func testIamPermissions(
      request: GoogleIAMV1.TestIamPermissionsRequest, options: GoogleCloudGax.RequestOptions
    ) async throws -> GoogleIAMV1.TestIamPermissionsResponse {
      let path = try { () throws -> Swift.String in
        guard let pathVariable0 = request.resource as Swift.String?, !pathVariable0.isEmpty else {
          throw GoogleCloudGax.RequestError.binding("'request.resource' is not set or is empty")
        }
        return "/v1/\(pathVariable0):testIamPermissions"
      }()
      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(
        GoogleIAMV1.TestIamPermissionsResponse.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 "/v1/\(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)
    }
  }
}
