// Generated by openapi-moonbit — DO NOT EDIT
// Spec SHA-256: 7e574664c0f434e52021e12f313a3266fd3175fe2ecddde4c0e0930549c72ba2
///|
/// Operations in the `Account` group. Implement this trait to mock or wrap `Client`.
pub(open) trait AccountClient {
async fn create_account(self : Self, body~ : @model.AccountCreation) -> @model.Account raise GolemError
async fn get_account(self : Self, account_id~ : @uuid.UUID) -> @model.Account raise GolemError
async fn delete_account(
self : Self,
account_id~ : @uuid.UUID,
current_revision~ : UInt64,
) -> @model.Empty raise GolemError
async fn update_account(
self : Self,
account_id~ : @uuid.UUID,
body~ : @model.AccountUpdate,
) -> @model.Account raise GolemError
async fn get_account_by_email(self : Self, account_email~ : String) -> @model.Account raise GolemError
async fn get_account_plan(self : Self, account_id~ : @uuid.UUID) -> @model.Plan raise GolemError
async fn set_account_plan(
self : Self,
account_id~ : @uuid.UUID,
body~ : @model.AccountSetPlan,
) -> @model.Account raise GolemError
async fn list_account_deletion_holds(self : Self, account_id~ : @uuid.UUID) -> @model.PageAccountDeletionHold raise GolemError
async fn place_account_deletion_hold(
self : Self,
account_id~ : @uuid.UUID,
holder_account_id~ : @uuid.UUID,
body~ : @model.AccountDeletionHoldCreation,
) -> @model.AccountDeletionHold raise GolemError
async fn remove_account_deletion_hold(
self : Self,
account_id~ : @uuid.UUID,
holder_account_id~ : @uuid.UUID,
) -> @model.Empty raise GolemError
async fn get_account_usage(
self : Self,
account_id~ : @uuid.UUID,
period? : String,
) -> @model.AccountUsage raise GolemError
async fn get_account_usage_history(
self : Self,
account_id~ : @uuid.UUID,
last? : UInt64,
) -> Array[@model.AccountUsage] raise GolemError
async fn get_account_limits(self : Self, account_id~ : @uuid.UUID) -> @model.AccountResourcePolicy raise GolemError
async fn set_account_monthly_usage_mode(
self : Self,
account_id~ : @uuid.UUID,
body~ : @model.SetMonthlyUsageMode,
) -> @model.MonthlyUsageModeTransition raise GolemError
async fn set_account_storage_override(
self : Self,
account_id~ : @uuid.UUID,
body~ : @model.SetStorageLimit,
) -> @model.StorageLimit raise GolemError
async fn clear_account_storage_override(self : Self, account_id~ : @uuid.UUID) -> @model.StorageLimit raise GolemError
async fn set_account_max_memory_override(
self : Self,
account_id~ : @uuid.UUID,
body~ : @model.SetMemoryLimit,
) -> @model.MemoryLimit raise GolemError
async fn clear_account_max_memory_override(
self : Self,
account_id~ : @uuid.UUID,
) -> @model.MemoryLimit raise GolemError
async fn set_account_admin_resource_grant(
self : Self,
account_id~ : @uuid.UUID,
dimension~ : @model.AdminResourceGrantDimension,
body~ : @model.SetAdminResourceGrant,
) -> @model.AdminResourceGrantChange raise GolemError
async fn clear_account_admin_resource_grant(
self : Self,
account_id~ : @uuid.UUID,
dimension~ : @model.AdminResourceGrantDimension,
) -> @model.ClearedAdminResourceGrantChange raise GolemError
async fn create_impersonation_token(
self : Self,
account_id~ : @uuid.UUID,
body~ : @model.TokenCreation,
) -> @model.TokenWithSecret raise GolemError
}
///|
/// Create a new account. The response is the created account data.
///
/// `POST /v1/accounts` (`create_account`).
pub impl[T : @runtime.Transport] AccountClient for Client[T] with fn create_account(
self : Client[T],
body~ : @model.AccountCreation,
) -> @model.Account raise GolemError {
let __path = "/v1/accounts"
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.Account)
})
_ => raise self.api_error_from_response(__resp)
}
}
///|
/// Retrieve an account for a given Account ID
///
/// `GET /v1/accounts/{account_id}` (`get_account`).
pub impl[T : @runtime.Transport] AccountClient for Client[T] with fn get_account(
self : Client[T],
account_id~ : @uuid.UUID,
) -> @model.Account 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}", __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.Account)
})
_ => raise self.api_error_from_response(__resp)
}
}
///|
/// Delete an account.
/// The delete fails with 409 while the account has a deletion hold. The error lists the
/// reasons of the holds.
///
/// `DELETE /v1/accounts/{account_id}` (`delete_account`).
pub impl[T : @runtime.Transport] AccountClient for Client[T] with fn delete_account(
self : Client[T],
account_id~ : @uuid.UUID,
current_revision~ : UInt64,
) -> @model.Empty 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}", __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 =>
if __resp.body().is_empty() {
@cjson.Json::null()
} else {
let __b = __resp.text()
@rjson.parse_json(__b) catch {
e => {
let __err = GolemError::Decode(
status=__resp.status(),
message=e.to_string(),
body=__b,
)
raise __err
}
}
}
_ => raise self.api_error_from_response(__resp)
}
}
///|
/// Update account
/// Allows the user to change mutable account details such as name.
///
/// The account email is immutable after account creation.
///
/// Changing the planId is not allowed and the request will be rejected.
/// The response is the updated account data.
///
/// `PATCH /v1/accounts/{account_id}` (`update_account`).
pub impl[T : @runtime.Transport] AccountClient for Client[T] with fn update_account(
self : Client[T],
account_id~ : @uuid.UUID,
body~ : @model.AccountUpdate,
) -> @model.Account 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}", __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.Account)
})
_ => raise self.api_error_from_response(__resp)
}
}
///|
/// Retrieve an account by email address.
///
/// `GET /v1/accounts/by-email/{account_email}` (`get_account_by_email`).
pub impl[T : @runtime.Transport] AccountClient for Client[T] with fn get_account_by_email(
self : Client[T],
account_email~ : String,
) -> @model.Account raise GolemError {
let __path_params : Array[(String, String)] = []
__path_params.push(("account_email", account_email))
let __path = self.expand_op_path(
"/v1/accounts/by-email/{account_email}", __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.Account)
})
_ => raise self.api_error_from_response(__resp)
}
}
///|
/// Get an account's plan
///
/// `GET /v1/accounts/{account_id}/plan` (`get_account_plan`).
pub impl[T : @runtime.Transport] AccountClient for Client[T] with fn get_account_plan(
self : Client[T],
account_id~ : @uuid.UUID,
) -> @model.Plan 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}/plan", __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.Plan)
})
_ => raise self.api_error_from_response(__resp)
}
}
///|
/// Set the plan of an account
///
/// `PUT /v1/accounts/{account_id}/plan` (`set_account_plan`).
pub impl[T : @runtime.Transport] AccountClient for Client[T] with fn set_account_plan(
self : Client[T],
account_id~ : @uuid.UUID,
body~ : @model.AccountSetPlan,
) -> @model.Account 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}/plan", __path_params,
)
let __req = self.prepare_request(http_method="PUT", 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.Account)
})
_ => raise self.api_error_from_response(__resp)
}
}
///|
/// List the deletion holds of an account.
/// While an account has a deletion hold, the account cannot be deleted.
///
/// `GET /v1/accounts/{account_id}/deletion-holds` (`list_account_deletion_holds`).
pub impl[T : @runtime.Transport] AccountClient for Client[T] with fn list_account_deletion_holds(
self : Client[T],
account_id~ : @uuid.UUID,
) -> @model.PageAccountDeletionHold 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}/deletion-holds", __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.PageAccountDeletionHold)
})
_ => raise self.api_error_from_response(__resp)
}
}
///|
/// Place a deletion hold on an account.
/// The holder is the account of the caller. An administrator with the
/// `override-deletion-hold` permission can also place a hold for another holder. When the
/// holder has a hold on the account already, the reason replaces the reason of that hold.
///
/// `PUT /v1/accounts/{account_id}/deletion-holds/{holder_account_id}` (`place_account_deletion_hold`).
pub impl[T : @runtime.Transport] AccountClient for Client[T] with fn place_account_deletion_hold(
self : Client[T],
account_id~ : @uuid.UUID,
holder_account_id~ : @uuid.UUID,
body~ : @model.AccountDeletionHoldCreation,
) -> @model.AccountDeletionHold raise GolemError {
let __path_params : Array[(String, String)] = []
__path_params.push(("account_id", account_id.to_string()))
__path_params.push(("holder_account_id", holder_account_id.to_string()))
let __path = self.expand_op_path(
"/v1/accounts/{account_id}/deletion-holds/{holder_account_id}", __path_params,
)
let __req = self.prepare_request(http_method="PUT", 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.AccountDeletionHold)
})
_ => raise self.api_error_from_response(__resp)
}
}
///|
/// Remove a deletion hold from an account.
/// The holder removes its own hold. An administrator with the `override-deletion-hold`
/// permission can remove the hold of any holder. Removing a hold that does not exist succeeds.
///
/// `DELETE /v1/accounts/{account_id}/deletion-holds/{holder_account_id}` (`remove_account_deletion_hold`).
pub impl[T : @runtime.Transport] AccountClient for Client[T] with fn remove_account_deletion_hold(
self : Client[T],
account_id~ : @uuid.UUID,
holder_account_id~ : @uuid.UUID,
) -> @model.Empty raise GolemError {
let __path_params : Array[(String, String)] = []
__path_params.push(("account_id", account_id.to_string()))
__path_params.push(("holder_account_id", holder_account_id.to_string()))
let __path = self.expand_op_path(
"/v1/accounts/{account_id}/deletion-holds/{holder_account_id}", __path_params,
)
let __req = self.prepare_request(http_method="DELETE", path=__path)
let __resp = self.send_request(__req)
match __resp.status() {
200 =>
if __resp.body().is_empty() {
@cjson.Json::null()
} else {
let __b = __resp.text()
@rjson.parse_json(__b) catch {
e => {
let __err = GolemError::Decode(
status=__resp.status(),
message=e.to_string(),
body=__b,
)
raise __err
}
}
}
_ => raise self.api_error_from_response(__resp)
}
}
///|
/// Get account usage for a UTC calendar month.
/// Compute is reported in GCU, memory in allocated linear-memory GB-seconds, and durable and
/// ephemeral storage in GB-month using byte-seconds / (1024^3 * 730 * 3600). `asOf` is when
/// the registry last received a usage snapshot for the period, or the response time if no
/// snapshot exists. Metering status distinguishes enabled meters that measured zero from
/// disabled meters. `unknown` means no usage producer has reported metering state for the
/// period. Durable and ephemeral storage both use storage metering.
///
/// `GET /v1/accounts/{account_id}/usage` (`get_account_usage`).
pub impl[T : @runtime.Transport] AccountClient for Client[T] with fn get_account_usage(
self : Client[T],
account_id~ : @uuid.UUID,
period? : String,
) -> @model.AccountUsage 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}/usage", __path_params,
)
let __qb = @encoding.QueryBuilder::new()
match period {
Option::Some(__qv) => {
let _ = __qb.add_scalar("period", __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.AccountUsage)
})
_ => raise self.api_error_from_response(__resp)
}
}
///|
/// Get sparse account usage for closed UTC calendar months, newest first.
/// Each item uses the same metrics and metering-status contract as current usage. The response
/// does not include plan or limit metadata because historical limits are not snapshotted.
///
/// `GET /v1/accounts/{account_id}/usage/history` (`get_account_usage_history`).
pub impl[T : @runtime.Transport] AccountClient for Client[T] with fn get_account_usage_history(
self : Client[T],
account_id~ : @uuid.UUID,
last? : UInt64,
) -> Array[@model.AccountUsage] 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}/usage/history", __path_params,
)
let __qb = @encoding.QueryBuilder::new()
match last {
Option::Some(__qv) => {
let _ = __qb.add_scalar("last", @encoding.format_uint64(__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 => {
__r
.read_array()
.map(__el_0 => {
(
@cjson.FromJson::from_json(__el_0.raw(), __el_0.context()) :
@model.AccountUsage)
})
})
_ => raise self.api_error_from_response(__resp)
}
}
///|
/// Get the current account resource policy.
/// The policy combines Plan Row monthly amounts with current UTC-period usage and both
/// per-agent safety limits. Enabled monthly dimensions report measured usage and remaining
/// capacity. Disabled dimensions omit the monthly amount, usage, remaining capacity, and
/// behavior. `unknown` means no producer has reported metering state; it does not mean disabled
/// or measured zero. Compute uses GCU, allocated linear memory uses GB-seconds, storage uses
/// GB-month, and per-agent limits use bytes. Monthly behavior is `hardLimit` or
/// `includedAllowance`, according to the account's current usage mode.
///
/// `GET /v1/accounts/{account_id}/limits` (`get_account_limits`).
pub impl[T : @runtime.Transport] AccountClient for Client[T] with fn get_account_limits(
self : Client[T],
account_id~ : @uuid.UUID,
) -> @model.AccountResourcePolicy 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}/limits", __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.AccountResourcePolicy)
})
_ => raise self.api_error_from_response(__resp)
}
}
///|
/// Explicitly enter or leave paid-overage mode.
/// Only the account owner can enable overage, and the current Plan Row must permit it.
/// Administrators impersonating the account may force `hardLimit`, but cannot enable overage.
/// Each successful transition records immutable consent history. Requests that repeat the
/// current mode are rejected and do not add history.
///
/// `PUT /v1/accounts/{account_id}/monthly-usage-mode` (`set_account_monthly_usage_mode`).
pub impl[T : @runtime.Transport] AccountClient for Client[T] with fn set_account_monthly_usage_mode(
self : Client[T],
account_id~ : @uuid.UUID,
body~ : @model.SetMonthlyUsageMode,
) -> @model.MonthlyUsageModeTransition 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}/monthly-usage-mode", __path_params,
)
let __req = self.prepare_request(http_method="PUT", 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.MonthlyUsageModeTransition)
})
_ => raise self.api_error_from_response(__resp)
}
}
///|
/// Set a storage-per-agent override for the authenticated account owner.
///
/// `PUT /v1/accounts/{account_id}/resource-overrides/max-storage-per-agent` (`set_account_storage_override`).
pub impl[T : @runtime.Transport] AccountClient for Client[T] with fn set_account_storage_override(
self : Client[T],
account_id~ : @uuid.UUID,
body~ : @model.SetStorageLimit,
) -> @model.StorageLimit 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}/resource-overrides/max-storage-per-agent", __path_params,
)
let __req = self.prepare_request(http_method="PUT", 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.StorageLimit)
})
_ => raise self.api_error_from_response(__resp)
}
}
///|
/// Clear a storage-per-agent override for an account.
///
/// `DELETE /v1/accounts/{account_id}/resource-overrides/max-storage-per-agent` (`clear_account_storage_override`).
pub impl[T : @runtime.Transport] AccountClient for Client[T] with fn clear_account_storage_override(
self : Client[T],
account_id~ : @uuid.UUID,
) -> @model.StorageLimit 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}/resource-overrides/max-storage-per-agent", __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.StorageLimit)
})
_ => raise self.api_error_from_response(__resp)
}
}
///|
/// Set the maximum linear memory per agent for the authenticated account owner.
///
/// `PUT /v1/accounts/{account_id}/resource-overrides/max-memory-per-agent` (`set_account_max_memory_override`).
pub impl[T : @runtime.Transport] AccountClient for Client[T] with fn set_account_max_memory_override(
self : Client[T],
account_id~ : @uuid.UUID,
body~ : @model.SetMemoryLimit,
) -> @model.MemoryLimit 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}/resource-overrides/max-memory-per-agent", __path_params,
)
let __req = self.prepare_request(http_method="PUT", 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.MemoryLimit)
})
_ => raise self.api_error_from_response(__resp)
}
}
///|
/// Clear the maximum linear memory per-agent override.
///
/// `DELETE /v1/accounts/{account_id}/resource-overrides/max-memory-per-agent` (`clear_account_max_memory_override`).
pub impl[T : @runtime.Transport] AccountClient for Client[T] with fn clear_account_max_memory_override(
self : Client[T],
account_id~ : @uuid.UUID,
) -> @model.MemoryLimit 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}/resource-overrides/max-memory-per-agent", __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.MemoryLimit)
})
_ => raise self.api_error_from_response(__resp)
}
}
///|
/// Grant an account additional resources.
/// This operation requires an administrator token. Promotional grants require a future
/// expiry. Grants do not change the account's paid-overage consent.
///
/// `PUT /v1/accounts/{account_id}/resource-grants/{dimension}` (`set_account_admin_resource_grant`).
pub impl[T : @runtime.Transport] AccountClient for Client[T] with fn set_account_admin_resource_grant(
self : Client[T],
account_id~ : @uuid.UUID,
dimension~ : @model.AdminResourceGrantDimension,
body~ : @model.SetAdminResourceGrant,
) -> @model.AdminResourceGrantChange raise GolemError {
let __path_params : Array[(String, String)] = []
__path_params.push(("account_id", account_id.to_string()))
__path_params.push(("dimension", dimension.to_wire()))
let __path = self.expand_op_path(
"/v1/accounts/{account_id}/resource-grants/{dimension}", __path_params,
)
let __req = self.prepare_request(http_method="PUT", 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.AdminResourceGrantChange)
})
_ => raise self.api_error_from_response(__resp)
}
}
///|
/// Clear an active admin resource grant.
///
/// `DELETE /v1/accounts/{account_id}/resource-grants/{dimension}` (`clear_account_admin_resource_grant`).
pub impl[T : @runtime.Transport] AccountClient for Client[T] with fn clear_account_admin_resource_grant(
self : Client[T],
account_id~ : @uuid.UUID,
dimension~ : @model.AdminResourceGrantDimension,
) -> @model.ClearedAdminResourceGrantChange raise GolemError {
let __path_params : Array[(String, String)] = []
__path_params.push(("account_id", account_id.to_string()))
__path_params.push(("dimension", dimension.to_wire()))
let __path = self.expand_op_path(
"/v1/accounts/{account_id}/resource-grants/{dimension}", __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.ClearedAdminResourceGrantChange)
})
_ => raise self.api_error_from_response(__resp)
}
}
///|
/// Create an impersonation token for a target account
/// Creates a short-lived token that, when used for authentication, produces an
/// `AdminImpersonation` auth context: access and visibility checks run as the
/// target account, but audit writes (created_by fields) record the admin's account ID.
///
/// Only users with the `Admin` account role may call this endpoint.
///
/// `POST /v1/admin/impersonate/{account_id}` (`create_impersonation_token`).
pub impl[T : @runtime.Transport] AccountClient for Client[T] with fn create_impersonation_token(
self : Client[T],
account_id~ : @uuid.UUID,
body~ : @model.TokenCreation,
) -> @model.TokenWithSecret raise GolemError {
let __path_params : Array[(String, String)] = []
__path_params.push(("account_id", account_id.to_string()))
let __path = self.expand_op_path(
"/v1/admin/impersonate/{account_id}", __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.TokenWithSecret)
})
_ => raise self.api_error_from_response(__resp)
}
}
///|
pub extend Client with AccountClient::{
create_account,
get_account,
delete_account,
update_account,
get_account_by_email,
get_account_plan,
set_account_plan,
list_account_deletion_holds,
place_account_deletion_hold,
remove_account_deletion_hold,
get_account_usage,
get_account_usage_history,
get_account_limits,
set_account_monthly_usage_mode,
set_account_storage_override,
clear_account_storage_override,
set_account_max_memory_override,
clear_account_max_memory_override,
set_account_admin_resource_grant,
clear_account_admin_resource_grant,
create_impersonation_token,
}