// Generated by openapi-moonbit — DO NOT EDIT
// Spec SHA-256: 7e574664c0f434e52021e12f313a3266fd3175fe2ecddde4c0e0930549c72ba2
///|
/// Operations in the `Me` group. Implement this trait to mock or wrap `Client`.
pub(open) trait MeClient {
async fn current_login_token(self : Self) -> @model.Token raise GolemError
async fn list_visible_environments(
self : Self,
account_email? : String,
app_name? : String,
env_name? : String,
) -> @model.PageEnvironmentWithDetails raise GolemError
}
///|
/// Gets information about the current token.
/// The JSON is the same as the data object in the oauth2 endpoint's response.
///
/// `GET /v1/me/token` (`current_login_token`).
pub impl[T : @runtime.Transport] MeClient for Client[T] with fn current_login_token(
self : Client[T],
) -> @model.Token raise GolemError {
let __path = "/v1/me/token"
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.Token)
})
_ => raise self.api_error_from_response(__resp)
}
}
///|
/// List all environments that are visible to the current user, either directly or through shares.
///
/// `GET /v1/me/visible-environments` (`list_visible_environments`).
pub impl[T : @runtime.Transport] MeClient for Client[T] with fn list_visible_environments(
self : Client[T],
account_email? : String,
app_name? : String,
env_name? : String,
) -> @model.PageEnvironmentWithDetails raise GolemError {
let __path = "/v1/me/visible-environments"
let __qb = @encoding.QueryBuilder::new()
match account_email {
Option::Some(__qv) => {
let _ = __qb.add_scalar("account_email", __qv)
}
Option::None => ()
}
match app_name {
Option::Some(__qv) => {
let _ = __qb.add_scalar("app_name", __qv)
}
Option::None => ()
}
match env_name {
Option::Some(__qv) => {
let _ = __qb.add_scalar("env_name", __qv)
}
Option::None => ()
}
let __req = self.prepare_request(
http_method="GET",
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.PageEnvironmentWithDetails)
})
_ => raise self.api_error_from_response(__resp)
}
}
///|
pub extend Client with MeClient::{
current_login_token,
list_visible_environments,
}