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

///|
/// Operations in the `ApiSecurity` group. Implement this trait to mock or wrap `Client`.
pub(open) trait ApiSecurityClient {
  async fn list_environment_security_schemes(
    self : Self,
    environment_id~ : @uuid.UUID,
  ) -> @model.PageSecuritySchemeDto raise GolemError
  async fn create_security_scheme(
    self : Self,
    environment_id~ : @uuid.UUID,
    body~ : @model.SecuritySchemeCreation,
  ) -> @model.SecuritySchemeDto raise GolemError
  async fn get_environment_security_scheme(
    self : Self,
    environment_id~ : @uuid.UUID,
    security_scheme_name~ : String,
  ) -> @model.SecuritySchemeDto raise GolemError
  async fn get_security_scheme(self : Self, security_scheme_id~ : @uuid.UUID) -> @model.SecuritySchemeDto raise GolemError
  async fn delete_security_scheme(
    self : Self,
    security_scheme_id~ : @uuid.UUID,
    current_revision~ : UInt64,
  ) -> @model.SecuritySchemeDto raise GolemError
  async fn update_security_scheme(
    self : Self,
    security_scheme_id~ : @uuid.UUID,
    body~ : @model.SecuritySchemeUpdate,
  ) -> @model.SecuritySchemeDto raise GolemError
}

///|
/// Get all security-schemes of the environment
///
/// `GET /v1/envs/{environment_id}/security-schemes` (`list_environment_security_schemes`).
pub impl[T : @runtime.Transport] ApiSecurityClient for Client[T] with fn list_environment_security_schemes(
  self : Client[T],
  environment_id~ : @uuid.UUID,
) -> @model.PageSecuritySchemeDto raise GolemError {
  let __path_params : Array[(String, String)] = []
  __path_params.push(("environment_id", environment_id.to_string()))
  let __path = self.expand_op_path(
    "/v1/envs/{environment_id}/security-schemes", __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.PageSecuritySchemeDto)
      })
    _ => raise self.api_error_from_response(__resp)
  }
}

///|
/// Create a new security scheme
///
/// `POST /v1/envs/{environment_id}/security-schemes` (`create_security_scheme`).
pub impl[T : @runtime.Transport] ApiSecurityClient for Client[T] with fn create_security_scheme(
  self : Client[T],
  environment_id~ : @uuid.UUID,
  body~ : @model.SecuritySchemeCreation,
) -> @model.SecuritySchemeDto raise GolemError {
  let __path_params : Array[(String, String)] = []
  __path_params.push(("environment_id", environment_id.to_string()))
  let __path = self.expand_op_path(
    "/v1/envs/{environment_id}/security-schemes", __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.SecuritySchemeDto)
      })
    _ => raise self.api_error_from_response(__resp)
  }
}

///|
/// Get a security scheme in an environment by name.
///
/// `GET /v1/envs/{environment_id}/security-schemes/{security_scheme_name}` (`get_environment_security_scheme`).
pub impl[T : @runtime.Transport] ApiSecurityClient for Client[T] with fn get_environment_security_scheme(
  self : Client[T],
  environment_id~ : @uuid.UUID,
  security_scheme_name~ : String,
) -> @model.SecuritySchemeDto raise GolemError {
  let __path_params : Array[(String, String)] = []
  __path_params.push(("environment_id", environment_id.to_string()))
  __path_params.push(("security_scheme_name", security_scheme_name))
  let __path = self.expand_op_path(
    "/v1/envs/{environment_id}/security-schemes/{security_scheme_name}", __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.SecuritySchemeDto)
      })
    _ => raise self.api_error_from_response(__resp)
  }
}

///|
/// Get security scheme
///
/// `GET /v1/security-schemes/{security_scheme_id}` (`get_security_scheme`).
pub impl[T : @runtime.Transport] ApiSecurityClient for Client[T] with fn get_security_scheme(
  self : Client[T],
  security_scheme_id~ : @uuid.UUID,
) -> @model.SecuritySchemeDto raise GolemError {
  let __path_params : Array[(String, String)] = []
  __path_params.push(("security_scheme_id", security_scheme_id.to_string()))
  let __path = self.expand_op_path(
    "/v1/security-schemes/{security_scheme_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.SecuritySchemeDto)
      })
    _ => raise self.api_error_from_response(__resp)
  }
}

///|
/// Delete security scheme
///
/// `DELETE /v1/security-schemes/{security_scheme_id}` (`delete_security_scheme`).
pub impl[T : @runtime.Transport] ApiSecurityClient for Client[T] with fn delete_security_scheme(
  self : Client[T],
  security_scheme_id~ : @uuid.UUID,
  current_revision~ : UInt64,
) -> @model.SecuritySchemeDto raise GolemError {
  let __path_params : Array[(String, String)] = []
  __path_params.push(("security_scheme_id", security_scheme_id.to_string()))
  let __path = self.expand_op_path(
    "/v1/security-schemes/{security_scheme_id}", __path_params,
  )
  let __qb = @encoding.QueryBuilder::new()
  let _ = __qb.add_scalar(
    "current_revision",
    @encoding.format_uint64(current_revision),
  )
  let __req = self.prepare_request(
    http_method="DELETE",
    path=__path,
    query=__qb.build(),
  )
  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.SecuritySchemeDto)
      })
    _ => raise self.api_error_from_response(__resp)
  }
}

///|
/// Update security scheme
///
/// `PATCH /v1/security-schemes/{security_scheme_id}` (`update_security_scheme`).
pub impl[T : @runtime.Transport] ApiSecurityClient for Client[T] with fn update_security_scheme(
  self : Client[T],
  security_scheme_id~ : @uuid.UUID,
  body~ : @model.SecuritySchemeUpdate,
) -> @model.SecuritySchemeDto raise GolemError {
  let __path_params : Array[(String, String)] = []
  __path_params.push(("security_scheme_id", security_scheme_id.to_string()))
  let __path = self.expand_op_path(
    "/v1/security-schemes/{security_scheme_id}", __path_params,
  )
  let __req = self.prepare_request(http_method="PATCH", 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.SecuritySchemeDto)
      })
    _ => raise self.api_error_from_response(__resp)
  }
}

///|
pub extend Client with ApiSecurityClient::{
  list_environment_security_schemes,
  create_security_scheme,
  get_environment_security_scheme,
  get_security_scheme,
  delete_security_scheme,
  update_security_scheme,
}