cc_lb_plugin_wire/v1/
on_unauthorized.rs1extern crate alloc;
2
3use alloc::string::String;
4use serde::{Deserialize, Serialize};
5
6use crate::v1::common::UpstreamErrorWire;
7use crate::wire_function::{FallbackPolicy, WireFunction};
8
9#[derive(Clone, Debug, Serialize, Deserialize, PartialEq, Eq)]
10#[serde(deny_unknown_fields)]
11pub struct OnUnauthorizedRequest {
12 pub error: UpstreamErrorWire,
13 pub signer_state: serde_json::Value,
14}
15
16impl OnUnauthorizedRequest {
17 pub fn dry_run_sample() -> Self {
18 Self {
19 error: UpstreamErrorWire::dry_run_sample(),
20 signer_state: serde_json::Value::Null,
21 }
22 }
23}
24
25#[derive(Clone, Debug, Serialize, Deserialize, PartialEq, Eq)]
26#[serde(deny_unknown_fields)]
27pub struct OnUnauthorizedResponse {
28 pub decision: String,
29 pub signer_state: serde_json::Value,
30}
31
32impl OnUnauthorizedResponse {
33 pub fn dry_run_sample() -> Self {
34 Self {
35 decision: String::from("fail"),
36 signer_state: serde_json::Value::Null,
37 }
38 }
39}
40
41pub struct OnUnauthorizedFn;
42
43impl WireFunction for OnUnauthorizedFn {
44 const NAME: &'static str = "on_unauthorized";
45 const FALLBACK: FallbackPolicy = FallbackPolicy::PassThrough;
46 const SUPPORTED_VERSIONS: &'static [u32] = &[1];
47
48 type Request = OnUnauthorizedRequest;
49 type Response = OnUnauthorizedResponse;
50
51 fn dry_run_request() -> Self::Request {
52 OnUnauthorizedRequest::dry_run_sample()
53 }
54
55 fn dry_run_response() -> Self::Response {
56 OnUnauthorizedResponse::dry_run_sample()
57 }
58}