// Generated by openapi-moonbit — DO NOT EDIT
// Spec SHA-256: 7e574664c0f434e52021e12f313a3266fd3175fe2ecddde4c0e0930549c72ba2

///|
/// Operations in the `Plugin` group. Implement this trait to mock or wrap `Client`.
pub(open) trait PluginClient {
  async fn list_account_plugins(self : Self, account_id~ : @uuid.UUID) -> @model.PagePluginRegistrationDto raise GolemError
  async fn create_plugin(
    self : Self,
    account_id~ : @uuid.UUID,
    body~ : @model.PluginRegistrationCreation,
  ) -> @model.PluginRegistrationDto raise GolemError
  async fn get_account_plugin(
    self : Self,
    account_id~ : @uuid.UUID,
    plugin_name~ : String,
    plugin_version~ : String,
  ) -> @model.PluginRegistrationDto raise GolemError
  async fn get_account_plugin_by_email(
    self : Self,
    account_email~ : String,
    plugin_name~ : String,
    plugin_version~ : String,
  ) -> @model.PluginRegistrationDto raise GolemError
  async fn get_plugin_by_id(self : Self, plugin_id~ : @uuid.UUID) -> @model.PluginRegistrationDto raise GolemError
  async fn delete_plugin(self : Self, plugin_id~ : @uuid.UUID) -> @model.PluginRegistrationDto raise GolemError
}

///|
/// List all plugins registered in account
///
/// `GET /v1/accounts/{account_id}/plugins` (`list_account_plugins`).
pub impl[T : @runtime.Transport] PluginClient for Client[T] with fn list_account_plugins(
  self : Client[T],
  account_id~ : @uuid.UUID,
) -> @model.PagePluginRegistrationDto raise GolemError {
  let __path_params : Array[(String, String)] = []
  __path_params.push(("account_id", account_id.to_string()))
  let __path = self.expand_op_path(
    "/v1/accounts/{account_id}/plugins", __path_params,
  )
  let __req = self.prepare_request(http_method="GET", path=__path)
  let __resp = self.send_request(__req)
  match __resp.status() {
    200 =>
      self.decode_json_response(__resp, __r => {
        (
          @cjson.FromJson::from_json(__r.raw(), __r.context()) :
          @model.PagePluginRegistrationDto)
      })
    _ => raise self.api_error_from_response(__resp)
  }
}

///|
/// Register a new plugin
///
/// `POST /v1/accounts/{account_id}/plugins` (`create_plugin`).
pub impl[T : @runtime.Transport] PluginClient for Client[T] with fn create_plugin(
  self : Client[T],
  account_id~ : @uuid.UUID,
  body~ : @model.PluginRegistrationCreation,
) -> @model.PluginRegistrationDto raise GolemError {
  let __path_params : Array[(String, String)] = []
  __path_params.push(("account_id", account_id.to_string()))
  let __path = self.expand_op_path(
    "/v1/accounts/{account_id}/plugins", __path_params,
  )
  let __req = self.prepare_request(http_method="POST", path=__path)
  let _ = __req.with_body(
    content_type="application/json",
    body=@runtime.utf8_encode(body.to_json().stringify()),
  )
  let __resp = self.send_request(__req)
  match __resp.status() {
    200 =>
      self.decode_json_response(__resp, __r => {
        (
          @cjson.FromJson::from_json(__r.raw(), __r.context()) :
          @model.PluginRegistrationDto)
      })
    _ => raise self.api_error_from_response(__resp)
  }
}

///|
/// Get an account plugin by name and version.
///
/// `GET /v1/accounts/{account_id}/plugins/{plugin_name}/{plugin_version}` (`get_account_plugin`).
pub impl[T : @runtime.Transport] PluginClient for Client[T] with fn get_account_plugin(
  self : Client[T],
  account_id~ : @uuid.UUID,
  plugin_name~ : String,
  plugin_version~ : String,
) -> @model.PluginRegistrationDto raise GolemError {
  let __path_params : Array[(String, String)] = []
  __path_params.push(("account_id", account_id.to_string()))
  __path_params.push(("plugin_name", plugin_name))
  __path_params.push(("plugin_version", plugin_version))
  let __path = self.expand_op_path(
    "/v1/accounts/{account_id}/plugins/{plugin_name}/{plugin_version}", __path_params,
  )
  let __req = self.prepare_request(http_method="GET", path=__path)
  let __resp = self.send_request(__req)
  match __resp.status() {
    200 =>
      self.decode_json_response(__resp, __r => {
        (
          @cjson.FromJson::from_json(__r.raw(), __r.context()) :
          @model.PluginRegistrationDto)
      })
    _ => raise self.api_error_from_response(__resp)
  }
}

///|
/// Get an account plugin by the owner account's email, name and version.
/// Authorizes on the plugin permission alone — the same as the account-id form — resolving
/// the owner account from the email without an `AccountVerb::View` check, so the email and id
/// account scopes behave identically under granular sharing.
///
/// `GET /v1/accounts/by-email/{account_email}/plugins/{plugin_name}/{plugin_version}` (`get_account_plugin_by_email`).
pub impl[T : @runtime.Transport] PluginClient for Client[T] with fn get_account_plugin_by_email(
  self : Client[T],
  account_email~ : String,
  plugin_name~ : String,
  plugin_version~ : String,
) -> @model.PluginRegistrationDto raise GolemError {
  let __path_params : Array[(String, String)] = []
  __path_params.push(("account_email", account_email))
  __path_params.push(("plugin_name", plugin_name))
  __path_params.push(("plugin_version", plugin_version))
  let __path = self.expand_op_path(
    "/v1/accounts/by-email/{account_email}/plugins/{plugin_name}/{plugin_version}",
    __path_params,
  )
  let __req = self.prepare_request(http_method="GET", path=__path)
  let __resp = self.send_request(__req)
  match __resp.status() {
    200 =>
      self.decode_json_response(__resp, __r => {
        (
          @cjson.FromJson::from_json(__r.raw(), __r.context()) :
          @model.PluginRegistrationDto)
      })
    _ => raise self.api_error_from_response(__resp)
  }
}

///|
/// Get a plugin by id
///
/// `GET /v1/plugins/{plugin_id}` (`get_plugin_by_id`).
pub impl[T : @runtime.Transport] PluginClient for Client[T] with fn get_plugin_by_id(
  self : Client[T],
  plugin_id~ : @uuid.UUID,
) -> @model.PluginRegistrationDto raise GolemError {
  let __path_params : Array[(String, String)] = []
  __path_params.push(("plugin_id", plugin_id.to_string()))
  let __path = self.expand_op_path("/v1/plugins/{plugin_id}", __path_params)
  let __req = self.prepare_request(http_method="GET", path=__path)
  let __resp = self.send_request(__req)
  match __resp.status() {
    200 =>
      self.decode_json_response(__resp, __r => {
        (
          @cjson.FromJson::from_json(__r.raw(), __r.context()) :
          @model.PluginRegistrationDto)
      })
    _ => raise self.api_error_from_response(__resp)
  }
}

///|
/// Delete a plugin
///
/// `DELETE /v1/plugins/{plugin_id}` (`delete_plugin`).
pub impl[T : @runtime.Transport] PluginClient for Client[T] with fn delete_plugin(
  self : Client[T],
  plugin_id~ : @uuid.UUID,
) -> @model.PluginRegistrationDto raise GolemError {
  let __path_params : Array[(String, String)] = []
  __path_params.push(("plugin_id", plugin_id.to_string()))
  let __path = self.expand_op_path("/v1/plugins/{plugin_id}", __path_params)
  let __req = self.prepare_request(http_method="DELETE", path=__path)
  let __resp = self.send_request(__req)
  match __resp.status() {
    200 =>
      self.decode_json_response(__resp, __r => {
        (
          @cjson.FromJson::from_json(__r.raw(), __r.context()) :
          @model.PluginRegistrationDto)
      })
    _ => raise self.api_error_from_response(__resp)
  }
}

///|
pub extend Client with PluginClient::{
  list_account_plugins,
  create_plugin,
  get_account_plugin,
  get_account_plugin_by_email,
  get_plugin_by_id,
  delete_plugin,
}