1use serde::{Deserialize, Serialize};
2
3use super::{Content, JsonMap, Tool, ToolConfig};
4
5pub type CreateCachedContentRequest = CachedContent;
6pub type CreateCachedContentResponse = CachedContent;
7pub type GetCachedContentResponse = CachedContent;
8pub type UpdateCachedContentRequest = CachedContent;
9pub type UpdateCachedContentResponse = CachedContent;
10pub type DeleteCachedContentResponse = JsonMap;
11
12#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, Default)]
13#[serde(rename_all = "camelCase")]
14#[derive(gproxy_protocol_macros::WireBuilder)]
15#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
16pub struct CachedContent {
17 #[serde(default, skip_serializing_if = "Vec::is_empty")]
18 pub contents: Vec<Content>,
19 #[serde(default, skip_serializing_if = "Vec::is_empty")]
20 pub tools: Vec<Tool>,
21 #[serde(skip_serializing_if = "Option::is_none")]
22 pub create_time: Option<String>,
23 #[serde(skip_serializing_if = "Option::is_none")]
24 pub update_time: Option<String>,
25 #[serde(skip_serializing_if = "Option::is_none")]
26 pub usage_metadata: Option<CachedContentUsageMetadata>,
27 #[serde(flatten, skip_serializing_if = "Option::is_none")]
28 pub expiration: Option<CachedContentExpiration>,
29 #[serde(skip_serializing_if = "Option::is_none")]
30 pub name: Option<String>,
31 #[serde(skip_serializing_if = "Option::is_none")]
32 pub display_name: Option<String>,
33 #[serde(skip_serializing_if = "Option::is_none")]
34 pub model: Option<String>,
35 #[serde(skip_serializing_if = "Option::is_none")]
36 pub system_instruction: Option<Content>,
37 #[serde(skip_serializing_if = "Option::is_none")]
38 pub tool_config: Option<ToolConfig>,
39 #[serde(default, flatten, skip_serializing_if = "JsonMap::is_empty")]
40 pub rest: JsonMap,
41}
42
43#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
44#[serde(untagged)]
45#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
46pub enum CachedContentExpiration {
47 ExpireTime {
48 #[serde(rename = "expireTime")]
49 expire_time: String,
50 },
51 Ttl {
52 ttl: String,
53 },
54}
55
56#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, Default)]
57#[serde(rename_all = "camelCase")]
58#[derive(gproxy_protocol_macros::WireBuilder)]
59#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
60pub struct CachedContentUsageMetadata {
61 #[serde(skip_serializing_if = "Option::is_none")]
62 pub total_token_count: Option<i32>,
63 #[serde(default, flatten, skip_serializing_if = "JsonMap::is_empty")]
64 pub rest: JsonMap,
65}
66
67#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, Default)]
68#[serde(rename_all = "camelCase")]
69#[derive(gproxy_protocol_macros::WireBuilder)]
70#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
71pub struct ListCachedContentsRequest {
72 #[serde(skip_serializing_if = "Option::is_none")]
73 pub page_size: Option<i32>,
74 #[serde(skip_serializing_if = "Option::is_none")]
75 pub page_token: Option<String>,
76 #[serde(default, flatten, skip_serializing_if = "JsonMap::is_empty")]
77 pub rest: JsonMap,
78}
79
80#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, Default)]
81#[serde(rename_all = "camelCase")]
82#[derive(gproxy_protocol_macros::WireBuilder)]
83#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
84pub struct ListCachedContentsResponse {
85 #[serde(default, skip_serializing_if = "Vec::is_empty")]
86 pub cached_contents: Vec<CachedContent>,
87 #[serde(skip_serializing_if = "Option::is_none")]
88 pub next_page_token: Option<String>,
89 #[serde(default, flatten, skip_serializing_if = "JsonMap::is_empty")]
90 pub rest: JsonMap,
91}
92
93#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, Default)]
94#[serde(rename_all = "camelCase")]
95#[derive(gproxy_protocol_macros::WireBuilder)]
96#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
97pub struct GetCachedContentRequest {
98 #[serde(skip_serializing_if = "Option::is_none")]
99 pub name: Option<String>,
100 #[serde(default, flatten, skip_serializing_if = "JsonMap::is_empty")]
101 pub rest: JsonMap,
102}
103
104#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, Default)]
105#[serde(rename_all = "camelCase")]
106#[derive(gproxy_protocol_macros::WireBuilder)]
107#[cfg_attr(not(feature = "exhaustive"), non_exhaustive)]
108pub struct UpdateCachedContentQuery {
109 #[serde(skip_serializing_if = "Option::is_none")]
110 pub update_mask: Option<String>,
111 #[serde(default, flatten, skip_serializing_if = "JsonMap::is_empty")]
112 pub rest: JsonMap,
113}
114
115pub type DeleteCachedContentRequest = GetCachedContentRequest;
116
117pub type CreateCachedContentRequestBody = CreateCachedContentRequest;
118pub type CreateCachedContentResponseBody = CreateCachedContentResponse;
119pub type GetCachedContentResponseBody = GetCachedContentResponse;
120pub type UpdateCachedContentRequestBody = UpdateCachedContentRequest;
121pub type UpdateCachedContentResponseBody = UpdateCachedContentResponse;
122pub type DeleteCachedContentResponseBody = DeleteCachedContentResponse;
123pub type ListCachedContentsResponseBody = ListCachedContentsResponse;