generated-client.go 91 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031
  1. // Package client provides primitives to interact with the openapi HTTP API.
  2. //
  3. // Code generated by github.com/oapi-codegen/oapi-codegen/v2 version v2.4.1 DO NOT EDIT.
  4. package client
  5. import (
  6. "bytes"
  7. "context"
  8. "encoding/json"
  9. "errors"
  10. "fmt"
  11. "io"
  12. "net/http"
  13. "net/url"
  14. "strings"
  15. "github.com/oapi-codegen/runtime"
  16. )
  17. // Defines values for MessageInfoRole.
  18. const (
  19. Assistant MessageInfoRole = "assistant"
  20. User MessageInfoRole = "user"
  21. )
  22. // AppInfo defines model for App.Info.
  23. type AppInfo struct {
  24. Git bool `json:"git"`
  25. Path struct {
  26. Config string `json:"config"`
  27. Cwd string `json:"cwd"`
  28. Data string `json:"data"`
  29. Root string `json:"root"`
  30. } `json:"path"`
  31. Time struct {
  32. Initialized *float32 `json:"initialized,omitempty"`
  33. } `json:"time"`
  34. User string `json:"user"`
  35. }
  36. // Error defines model for Error.
  37. type Error struct {
  38. Data map[string]interface{} `json:"data"`
  39. }
  40. // Event defines model for Event.
  41. type Event struct {
  42. union json.RawMessage
  43. }
  44. // EventLspClientDiagnostics defines model for Event.lsp.client.diagnostics.
  45. type EventLspClientDiagnostics struct {
  46. Properties struct {
  47. Path string `json:"path"`
  48. ServerID string `json:"serverID"`
  49. } `json:"properties"`
  50. Type string `json:"type"`
  51. }
  52. // EventMessagePartUpdated defines model for Event.message.part.updated.
  53. type EventMessagePartUpdated struct {
  54. Properties struct {
  55. MessageID string `json:"messageID"`
  56. Part MessagePart `json:"part"`
  57. SessionID string `json:"sessionID"`
  58. } `json:"properties"`
  59. Type string `json:"type"`
  60. }
  61. // EventMessageUpdated defines model for Event.message.updated.
  62. type EventMessageUpdated struct {
  63. Properties struct {
  64. Info MessageInfo `json:"info"`
  65. } `json:"properties"`
  66. Type string `json:"type"`
  67. }
  68. // EventPermissionUpdated defines model for Event.permission.updated.
  69. type EventPermissionUpdated struct {
  70. Properties PermissionInfo `json:"properties"`
  71. Type string `json:"type"`
  72. }
  73. // EventSessionError defines model for Event.session.error.
  74. type EventSessionError struct {
  75. Properties struct {
  76. Error *EventSessionError_Properties_Error `json:"error,omitempty"`
  77. } `json:"properties"`
  78. Type string `json:"type"`
  79. }
  80. // EventSessionError_Properties_Error defines model for EventSessionError.Properties.Error.
  81. type EventSessionError_Properties_Error struct {
  82. union json.RawMessage
  83. }
  84. // EventSessionUpdated defines model for Event.session.updated.
  85. type EventSessionUpdated struct {
  86. Properties struct {
  87. Info SessionInfo `json:"info"`
  88. } `json:"properties"`
  89. Type string `json:"type"`
  90. }
  91. // EventStorageWrite defines model for Event.storage.write.
  92. type EventStorageWrite struct {
  93. Properties struct {
  94. Content *interface{} `json:"content,omitempty"`
  95. Key string `json:"key"`
  96. } `json:"properties"`
  97. Type string `json:"type"`
  98. }
  99. // MessageInfo defines model for Message.Info.
  100. type MessageInfo struct {
  101. Id string `json:"id"`
  102. Metadata struct {
  103. Assistant *struct {
  104. Cost float32 `json:"cost"`
  105. ModelID string `json:"modelID"`
  106. Path struct {
  107. Cwd string `json:"cwd"`
  108. Root string `json:"root"`
  109. } `json:"path"`
  110. ProviderID string `json:"providerID"`
  111. Summary *bool `json:"summary,omitempty"`
  112. System []string `json:"system"`
  113. Tokens struct {
  114. Cache struct {
  115. Read float32 `json:"read"`
  116. Write float32 `json:"write"`
  117. } `json:"cache"`
  118. Input float32 `json:"input"`
  119. Output float32 `json:"output"`
  120. Reasoning float32 `json:"reasoning"`
  121. } `json:"tokens"`
  122. } `json:"assistant,omitempty"`
  123. Error *MessageInfo_Metadata_Error `json:"error,omitempty"`
  124. SessionID string `json:"sessionID"`
  125. Time struct {
  126. Completed *float32 `json:"completed,omitempty"`
  127. Created float32 `json:"created"`
  128. } `json:"time"`
  129. Tool map[string]MessageInfo_Metadata_Tool_AdditionalProperties `json:"tool"`
  130. } `json:"metadata"`
  131. Parts []MessagePart `json:"parts"`
  132. Role MessageInfoRole `json:"role"`
  133. }
  134. // MessageInfo_Metadata_Error defines model for MessageInfo.Metadata.Error.
  135. type MessageInfo_Metadata_Error struct {
  136. union json.RawMessage
  137. }
  138. // MessageInfo_Metadata_Tool_AdditionalProperties defines model for MessageInfo.Metadata.Tool.AdditionalProperties.
  139. type MessageInfo_Metadata_Tool_AdditionalProperties struct {
  140. Time struct {
  141. End float32 `json:"end"`
  142. Start float32 `json:"start"`
  143. } `json:"time"`
  144. Title string `json:"title"`
  145. AdditionalProperties map[string]interface{} `json:"-"`
  146. }
  147. // MessageInfoRole defines model for MessageInfo.Role.
  148. type MessageInfoRole string
  149. // MessagePart defines model for Message.Part.
  150. type MessagePart struct {
  151. union json.RawMessage
  152. }
  153. // MessagePartFile defines model for Message.Part.File.
  154. type MessagePartFile struct {
  155. Filename *string `json:"filename,omitempty"`
  156. MediaType string `json:"mediaType"`
  157. Type string `json:"type"`
  158. Url string `json:"url"`
  159. }
  160. // MessagePartReasoning defines model for Message.Part.Reasoning.
  161. type MessagePartReasoning struct {
  162. ProviderMetadata *map[string]interface{} `json:"providerMetadata,omitempty"`
  163. Text string `json:"text"`
  164. Type string `json:"type"`
  165. }
  166. // MessagePartSourceUrl defines model for Message.Part.SourceUrl.
  167. type MessagePartSourceUrl struct {
  168. ProviderMetadata *map[string]interface{} `json:"providerMetadata,omitempty"`
  169. SourceId string `json:"sourceId"`
  170. Title *string `json:"title,omitempty"`
  171. Type string `json:"type"`
  172. Url string `json:"url"`
  173. }
  174. // MessagePartStepStart defines model for Message.Part.StepStart.
  175. type MessagePartStepStart struct {
  176. Type string `json:"type"`
  177. }
  178. // MessagePartText defines model for Message.Part.Text.
  179. type MessagePartText struct {
  180. Text string `json:"text"`
  181. Type string `json:"type"`
  182. }
  183. // MessagePartToolInvocation defines model for Message.Part.ToolInvocation.
  184. type MessagePartToolInvocation struct {
  185. ToolInvocation MessageToolInvocation `json:"toolInvocation"`
  186. Type string `json:"type"`
  187. }
  188. // MessageToolInvocation defines model for Message.ToolInvocation.
  189. type MessageToolInvocation struct {
  190. union json.RawMessage
  191. }
  192. // MessageToolInvocationToolCall defines model for Message.ToolInvocation.ToolCall.
  193. type MessageToolInvocationToolCall struct {
  194. Args *interface{} `json:"args,omitempty"`
  195. State string `json:"state"`
  196. Step *float32 `json:"step,omitempty"`
  197. ToolCallId string `json:"toolCallId"`
  198. ToolName string `json:"toolName"`
  199. }
  200. // MessageToolInvocationToolPartialCall defines model for Message.ToolInvocation.ToolPartialCall.
  201. type MessageToolInvocationToolPartialCall struct {
  202. Args *interface{} `json:"args,omitempty"`
  203. State string `json:"state"`
  204. Step *float32 `json:"step,omitempty"`
  205. ToolCallId string `json:"toolCallId"`
  206. ToolName string `json:"toolName"`
  207. }
  208. // MessageToolInvocationToolResult defines model for Message.ToolInvocation.ToolResult.
  209. type MessageToolInvocationToolResult struct {
  210. Args *interface{} `json:"args,omitempty"`
  211. Result string `json:"result"`
  212. State string `json:"state"`
  213. Step *float32 `json:"step,omitempty"`
  214. ToolCallId string `json:"toolCallId"`
  215. ToolName string `json:"toolName"`
  216. }
  217. // ModelInfo defines model for Model.Info.
  218. type ModelInfo struct {
  219. Attachment bool `json:"attachment"`
  220. Cost struct {
  221. Input float32 `json:"input"`
  222. InputCached float32 `json:"inputCached"`
  223. Output float32 `json:"output"`
  224. OutputCached float32 `json:"outputCached"`
  225. } `json:"cost"`
  226. Id string `json:"id"`
  227. Limit struct {
  228. Context float32 `json:"context"`
  229. Output float32 `json:"output"`
  230. } `json:"limit"`
  231. Name string `json:"name"`
  232. Reasoning bool `json:"reasoning"`
  233. Temperature bool `json:"temperature"`
  234. }
  235. // ProviderInfo defines model for Provider.Info.
  236. type ProviderInfo struct {
  237. Env []string `json:"env"`
  238. Id string `json:"id"`
  239. Models map[string]ModelInfo `json:"models"`
  240. Name string `json:"name"`
  241. }
  242. // ProviderAuthError defines model for ProviderAuthError.
  243. type ProviderAuthError struct {
  244. Data struct {
  245. Message string `json:"message"`
  246. ProviderID string `json:"providerID"`
  247. } `json:"data"`
  248. Name string `json:"name"`
  249. }
  250. // UnknownError defines model for UnknownError.
  251. type UnknownError struct {
  252. Data struct {
  253. Message string `json:"message"`
  254. } `json:"data"`
  255. Name string `json:"name"`
  256. }
  257. // PermissionInfo defines model for permission.info.
  258. type PermissionInfo struct {
  259. Id string `json:"id"`
  260. Metadata map[string]interface{} `json:"metadata"`
  261. SessionID string `json:"sessionID"`
  262. Time struct {
  263. Created float32 `json:"created"`
  264. } `json:"time"`
  265. Title string `json:"title"`
  266. }
  267. // SessionInfo defines model for session.info.
  268. type SessionInfo struct {
  269. Id string `json:"id"`
  270. ParentID *string `json:"parentID,omitempty"`
  271. Share *struct {
  272. Secret string `json:"secret"`
  273. Url string `json:"url"`
  274. } `json:"share,omitempty"`
  275. Time struct {
  276. Created float32 `json:"created"`
  277. Updated float32 `json:"updated"`
  278. } `json:"time"`
  279. Title string `json:"title"`
  280. }
  281. // PostFileSearchJSONBody defines parameters for PostFileSearch.
  282. type PostFileSearchJSONBody struct {
  283. Query string `json:"query"`
  284. }
  285. // PostSessionAbortJSONBody defines parameters for PostSessionAbort.
  286. type PostSessionAbortJSONBody struct {
  287. SessionID string `json:"sessionID"`
  288. }
  289. // PostSessionChatJSONBody defines parameters for PostSessionChat.
  290. type PostSessionChatJSONBody struct {
  291. ModelID string `json:"modelID"`
  292. Parts []MessagePart `json:"parts"`
  293. ProviderID string `json:"providerID"`
  294. SessionID string `json:"sessionID"`
  295. }
  296. // PostSessionInitializeJSONBody defines parameters for PostSessionInitialize.
  297. type PostSessionInitializeJSONBody struct {
  298. ModelID string `json:"modelID"`
  299. ProviderID string `json:"providerID"`
  300. SessionID string `json:"sessionID"`
  301. }
  302. // PostSessionMessagesJSONBody defines parameters for PostSessionMessages.
  303. type PostSessionMessagesJSONBody struct {
  304. SessionID string `json:"sessionID"`
  305. }
  306. // PostSessionShareJSONBody defines parameters for PostSessionShare.
  307. type PostSessionShareJSONBody struct {
  308. SessionID string `json:"sessionID"`
  309. }
  310. // PostSessionSummarizeJSONBody defines parameters for PostSessionSummarize.
  311. type PostSessionSummarizeJSONBody struct {
  312. ModelID string `json:"modelID"`
  313. ProviderID string `json:"providerID"`
  314. SessionID string `json:"sessionID"`
  315. }
  316. // PostFileSearchJSONRequestBody defines body for PostFileSearch for application/json ContentType.
  317. type PostFileSearchJSONRequestBody PostFileSearchJSONBody
  318. // PostSessionAbortJSONRequestBody defines body for PostSessionAbort for application/json ContentType.
  319. type PostSessionAbortJSONRequestBody PostSessionAbortJSONBody
  320. // PostSessionChatJSONRequestBody defines body for PostSessionChat for application/json ContentType.
  321. type PostSessionChatJSONRequestBody PostSessionChatJSONBody
  322. // PostSessionInitializeJSONRequestBody defines body for PostSessionInitialize for application/json ContentType.
  323. type PostSessionInitializeJSONRequestBody PostSessionInitializeJSONBody
  324. // PostSessionMessagesJSONRequestBody defines body for PostSessionMessages for application/json ContentType.
  325. type PostSessionMessagesJSONRequestBody PostSessionMessagesJSONBody
  326. // PostSessionShareJSONRequestBody defines body for PostSessionShare for application/json ContentType.
  327. type PostSessionShareJSONRequestBody PostSessionShareJSONBody
  328. // PostSessionSummarizeJSONRequestBody defines body for PostSessionSummarize for application/json ContentType.
  329. type PostSessionSummarizeJSONRequestBody PostSessionSummarizeJSONBody
  330. // Getter for additional properties for MessageInfo_Metadata_Tool_AdditionalProperties. Returns the specified
  331. // element and whether it was found
  332. func (a MessageInfo_Metadata_Tool_AdditionalProperties) Get(fieldName string) (value interface{}, found bool) {
  333. if a.AdditionalProperties != nil {
  334. value, found = a.AdditionalProperties[fieldName]
  335. }
  336. return
  337. }
  338. // Setter for additional properties for MessageInfo_Metadata_Tool_AdditionalProperties
  339. func (a *MessageInfo_Metadata_Tool_AdditionalProperties) Set(fieldName string, value interface{}) {
  340. if a.AdditionalProperties == nil {
  341. a.AdditionalProperties = make(map[string]interface{})
  342. }
  343. a.AdditionalProperties[fieldName] = value
  344. }
  345. // Override default JSON handling for MessageInfo_Metadata_Tool_AdditionalProperties to handle AdditionalProperties
  346. func (a *MessageInfo_Metadata_Tool_AdditionalProperties) UnmarshalJSON(b []byte) error {
  347. object := make(map[string]json.RawMessage)
  348. err := json.Unmarshal(b, &object)
  349. if err != nil {
  350. return err
  351. }
  352. if raw, found := object["time"]; found {
  353. err = json.Unmarshal(raw, &a.Time)
  354. if err != nil {
  355. return fmt.Errorf("error reading 'time': %w", err)
  356. }
  357. delete(object, "time")
  358. }
  359. if raw, found := object["title"]; found {
  360. err = json.Unmarshal(raw, &a.Title)
  361. if err != nil {
  362. return fmt.Errorf("error reading 'title': %w", err)
  363. }
  364. delete(object, "title")
  365. }
  366. if len(object) != 0 {
  367. a.AdditionalProperties = make(map[string]interface{})
  368. for fieldName, fieldBuf := range object {
  369. var fieldVal interface{}
  370. err := json.Unmarshal(fieldBuf, &fieldVal)
  371. if err != nil {
  372. return fmt.Errorf("error unmarshaling field %s: %w", fieldName, err)
  373. }
  374. a.AdditionalProperties[fieldName] = fieldVal
  375. }
  376. }
  377. return nil
  378. }
  379. // Override default JSON handling for MessageInfo_Metadata_Tool_AdditionalProperties to handle AdditionalProperties
  380. func (a MessageInfo_Metadata_Tool_AdditionalProperties) MarshalJSON() ([]byte, error) {
  381. var err error
  382. object := make(map[string]json.RawMessage)
  383. object["time"], err = json.Marshal(a.Time)
  384. if err != nil {
  385. return nil, fmt.Errorf("error marshaling 'time': %w", err)
  386. }
  387. object["title"], err = json.Marshal(a.Title)
  388. if err != nil {
  389. return nil, fmt.Errorf("error marshaling 'title': %w", err)
  390. }
  391. for fieldName, field := range a.AdditionalProperties {
  392. object[fieldName], err = json.Marshal(field)
  393. if err != nil {
  394. return nil, fmt.Errorf("error marshaling '%s': %w", fieldName, err)
  395. }
  396. }
  397. return json.Marshal(object)
  398. }
  399. // AsEventStorageWrite returns the union data inside the Event as a EventStorageWrite
  400. func (t Event) AsEventStorageWrite() (EventStorageWrite, error) {
  401. var body EventStorageWrite
  402. err := json.Unmarshal(t.union, &body)
  403. return body, err
  404. }
  405. // FromEventStorageWrite overwrites any union data inside the Event as the provided EventStorageWrite
  406. func (t *Event) FromEventStorageWrite(v EventStorageWrite) error {
  407. v.Type = "storage.write"
  408. b, err := json.Marshal(v)
  409. t.union = b
  410. return err
  411. }
  412. // MergeEventStorageWrite performs a merge with any union data inside the Event, using the provided EventStorageWrite
  413. func (t *Event) MergeEventStorageWrite(v EventStorageWrite) error {
  414. v.Type = "storage.write"
  415. b, err := json.Marshal(v)
  416. if err != nil {
  417. return err
  418. }
  419. merged, err := runtime.JSONMerge(t.union, b)
  420. t.union = merged
  421. return err
  422. }
  423. // AsEventLspClientDiagnostics returns the union data inside the Event as a EventLspClientDiagnostics
  424. func (t Event) AsEventLspClientDiagnostics() (EventLspClientDiagnostics, error) {
  425. var body EventLspClientDiagnostics
  426. err := json.Unmarshal(t.union, &body)
  427. return body, err
  428. }
  429. // FromEventLspClientDiagnostics overwrites any union data inside the Event as the provided EventLspClientDiagnostics
  430. func (t *Event) FromEventLspClientDiagnostics(v EventLspClientDiagnostics) error {
  431. v.Type = "lsp.client.diagnostics"
  432. b, err := json.Marshal(v)
  433. t.union = b
  434. return err
  435. }
  436. // MergeEventLspClientDiagnostics performs a merge with any union data inside the Event, using the provided EventLspClientDiagnostics
  437. func (t *Event) MergeEventLspClientDiagnostics(v EventLspClientDiagnostics) error {
  438. v.Type = "lsp.client.diagnostics"
  439. b, err := json.Marshal(v)
  440. if err != nil {
  441. return err
  442. }
  443. merged, err := runtime.JSONMerge(t.union, b)
  444. t.union = merged
  445. return err
  446. }
  447. // AsEventPermissionUpdated returns the union data inside the Event as a EventPermissionUpdated
  448. func (t Event) AsEventPermissionUpdated() (EventPermissionUpdated, error) {
  449. var body EventPermissionUpdated
  450. err := json.Unmarshal(t.union, &body)
  451. return body, err
  452. }
  453. // FromEventPermissionUpdated overwrites any union data inside the Event as the provided EventPermissionUpdated
  454. func (t *Event) FromEventPermissionUpdated(v EventPermissionUpdated) error {
  455. v.Type = "permission.updated"
  456. b, err := json.Marshal(v)
  457. t.union = b
  458. return err
  459. }
  460. // MergeEventPermissionUpdated performs a merge with any union data inside the Event, using the provided EventPermissionUpdated
  461. func (t *Event) MergeEventPermissionUpdated(v EventPermissionUpdated) error {
  462. v.Type = "permission.updated"
  463. b, err := json.Marshal(v)
  464. if err != nil {
  465. return err
  466. }
  467. merged, err := runtime.JSONMerge(t.union, b)
  468. t.union = merged
  469. return err
  470. }
  471. // AsEventMessageUpdated returns the union data inside the Event as a EventMessageUpdated
  472. func (t Event) AsEventMessageUpdated() (EventMessageUpdated, error) {
  473. var body EventMessageUpdated
  474. err := json.Unmarshal(t.union, &body)
  475. return body, err
  476. }
  477. // FromEventMessageUpdated overwrites any union data inside the Event as the provided EventMessageUpdated
  478. func (t *Event) FromEventMessageUpdated(v EventMessageUpdated) error {
  479. v.Type = "message.updated"
  480. b, err := json.Marshal(v)
  481. t.union = b
  482. return err
  483. }
  484. // MergeEventMessageUpdated performs a merge with any union data inside the Event, using the provided EventMessageUpdated
  485. func (t *Event) MergeEventMessageUpdated(v EventMessageUpdated) error {
  486. v.Type = "message.updated"
  487. b, err := json.Marshal(v)
  488. if err != nil {
  489. return err
  490. }
  491. merged, err := runtime.JSONMerge(t.union, b)
  492. t.union = merged
  493. return err
  494. }
  495. // AsEventMessagePartUpdated returns the union data inside the Event as a EventMessagePartUpdated
  496. func (t Event) AsEventMessagePartUpdated() (EventMessagePartUpdated, error) {
  497. var body EventMessagePartUpdated
  498. err := json.Unmarshal(t.union, &body)
  499. return body, err
  500. }
  501. // FromEventMessagePartUpdated overwrites any union data inside the Event as the provided EventMessagePartUpdated
  502. func (t *Event) FromEventMessagePartUpdated(v EventMessagePartUpdated) error {
  503. v.Type = "message.part.updated"
  504. b, err := json.Marshal(v)
  505. t.union = b
  506. return err
  507. }
  508. // MergeEventMessagePartUpdated performs a merge with any union data inside the Event, using the provided EventMessagePartUpdated
  509. func (t *Event) MergeEventMessagePartUpdated(v EventMessagePartUpdated) error {
  510. v.Type = "message.part.updated"
  511. b, err := json.Marshal(v)
  512. if err != nil {
  513. return err
  514. }
  515. merged, err := runtime.JSONMerge(t.union, b)
  516. t.union = merged
  517. return err
  518. }
  519. // AsEventSessionUpdated returns the union data inside the Event as a EventSessionUpdated
  520. func (t Event) AsEventSessionUpdated() (EventSessionUpdated, error) {
  521. var body EventSessionUpdated
  522. err := json.Unmarshal(t.union, &body)
  523. return body, err
  524. }
  525. // FromEventSessionUpdated overwrites any union data inside the Event as the provided EventSessionUpdated
  526. func (t *Event) FromEventSessionUpdated(v EventSessionUpdated) error {
  527. v.Type = "session.updated"
  528. b, err := json.Marshal(v)
  529. t.union = b
  530. return err
  531. }
  532. // MergeEventSessionUpdated performs a merge with any union data inside the Event, using the provided EventSessionUpdated
  533. func (t *Event) MergeEventSessionUpdated(v EventSessionUpdated) error {
  534. v.Type = "session.updated"
  535. b, err := json.Marshal(v)
  536. if err != nil {
  537. return err
  538. }
  539. merged, err := runtime.JSONMerge(t.union, b)
  540. t.union = merged
  541. return err
  542. }
  543. // AsEventSessionError returns the union data inside the Event as a EventSessionError
  544. func (t Event) AsEventSessionError() (EventSessionError, error) {
  545. var body EventSessionError
  546. err := json.Unmarshal(t.union, &body)
  547. return body, err
  548. }
  549. // FromEventSessionError overwrites any union data inside the Event as the provided EventSessionError
  550. func (t *Event) FromEventSessionError(v EventSessionError) error {
  551. v.Type = "session.error"
  552. b, err := json.Marshal(v)
  553. t.union = b
  554. return err
  555. }
  556. // MergeEventSessionError performs a merge with any union data inside the Event, using the provided EventSessionError
  557. func (t *Event) MergeEventSessionError(v EventSessionError) error {
  558. v.Type = "session.error"
  559. b, err := json.Marshal(v)
  560. if err != nil {
  561. return err
  562. }
  563. merged, err := runtime.JSONMerge(t.union, b)
  564. t.union = merged
  565. return err
  566. }
  567. func (t Event) Discriminator() (string, error) {
  568. var discriminator struct {
  569. Discriminator string `json:"type"`
  570. }
  571. err := json.Unmarshal(t.union, &discriminator)
  572. return discriminator.Discriminator, err
  573. }
  574. func (t Event) ValueByDiscriminator() (interface{}, error) {
  575. discriminator, err := t.Discriminator()
  576. if err != nil {
  577. return nil, err
  578. }
  579. switch discriminator {
  580. case "lsp.client.diagnostics":
  581. return t.AsEventLspClientDiagnostics()
  582. case "message.part.updated":
  583. return t.AsEventMessagePartUpdated()
  584. case "message.updated":
  585. return t.AsEventMessageUpdated()
  586. case "permission.updated":
  587. return t.AsEventPermissionUpdated()
  588. case "session.error":
  589. return t.AsEventSessionError()
  590. case "session.updated":
  591. return t.AsEventSessionUpdated()
  592. case "storage.write":
  593. return t.AsEventStorageWrite()
  594. default:
  595. return nil, errors.New("unknown discriminator value: " + discriminator)
  596. }
  597. }
  598. func (t Event) MarshalJSON() ([]byte, error) {
  599. b, err := t.union.MarshalJSON()
  600. return b, err
  601. }
  602. func (t *Event) UnmarshalJSON(b []byte) error {
  603. err := t.union.UnmarshalJSON(b)
  604. return err
  605. }
  606. // AsProviderAuthError returns the union data inside the EventSessionError_Properties_Error as a ProviderAuthError
  607. func (t EventSessionError_Properties_Error) AsProviderAuthError() (ProviderAuthError, error) {
  608. var body ProviderAuthError
  609. err := json.Unmarshal(t.union, &body)
  610. return body, err
  611. }
  612. // FromProviderAuthError overwrites any union data inside the EventSessionError_Properties_Error as the provided ProviderAuthError
  613. func (t *EventSessionError_Properties_Error) FromProviderAuthError(v ProviderAuthError) error {
  614. v.Name = "ProviderAuthError"
  615. b, err := json.Marshal(v)
  616. t.union = b
  617. return err
  618. }
  619. // MergeProviderAuthError performs a merge with any union data inside the EventSessionError_Properties_Error, using the provided ProviderAuthError
  620. func (t *EventSessionError_Properties_Error) MergeProviderAuthError(v ProviderAuthError) error {
  621. v.Name = "ProviderAuthError"
  622. b, err := json.Marshal(v)
  623. if err != nil {
  624. return err
  625. }
  626. merged, err := runtime.JSONMerge(t.union, b)
  627. t.union = merged
  628. return err
  629. }
  630. // AsUnknownError returns the union data inside the EventSessionError_Properties_Error as a UnknownError
  631. func (t EventSessionError_Properties_Error) AsUnknownError() (UnknownError, error) {
  632. var body UnknownError
  633. err := json.Unmarshal(t.union, &body)
  634. return body, err
  635. }
  636. // FromUnknownError overwrites any union data inside the EventSessionError_Properties_Error as the provided UnknownError
  637. func (t *EventSessionError_Properties_Error) FromUnknownError(v UnknownError) error {
  638. v.Name = "UnknownError"
  639. b, err := json.Marshal(v)
  640. t.union = b
  641. return err
  642. }
  643. // MergeUnknownError performs a merge with any union data inside the EventSessionError_Properties_Error, using the provided UnknownError
  644. func (t *EventSessionError_Properties_Error) MergeUnknownError(v UnknownError) error {
  645. v.Name = "UnknownError"
  646. b, err := json.Marshal(v)
  647. if err != nil {
  648. return err
  649. }
  650. merged, err := runtime.JSONMerge(t.union, b)
  651. t.union = merged
  652. return err
  653. }
  654. func (t EventSessionError_Properties_Error) Discriminator() (string, error) {
  655. var discriminator struct {
  656. Discriminator string `json:"name"`
  657. }
  658. err := json.Unmarshal(t.union, &discriminator)
  659. return discriminator.Discriminator, err
  660. }
  661. func (t EventSessionError_Properties_Error) ValueByDiscriminator() (interface{}, error) {
  662. discriminator, err := t.Discriminator()
  663. if err != nil {
  664. return nil, err
  665. }
  666. switch discriminator {
  667. case "ProviderAuthError":
  668. return t.AsProviderAuthError()
  669. case "UnknownError":
  670. return t.AsUnknownError()
  671. default:
  672. return nil, errors.New("unknown discriminator value: " + discriminator)
  673. }
  674. }
  675. func (t EventSessionError_Properties_Error) MarshalJSON() ([]byte, error) {
  676. b, err := t.union.MarshalJSON()
  677. return b, err
  678. }
  679. func (t *EventSessionError_Properties_Error) UnmarshalJSON(b []byte) error {
  680. err := t.union.UnmarshalJSON(b)
  681. return err
  682. }
  683. // AsProviderAuthError returns the union data inside the MessageInfo_Metadata_Error as a ProviderAuthError
  684. func (t MessageInfo_Metadata_Error) AsProviderAuthError() (ProviderAuthError, error) {
  685. var body ProviderAuthError
  686. err := json.Unmarshal(t.union, &body)
  687. return body, err
  688. }
  689. // FromProviderAuthError overwrites any union data inside the MessageInfo_Metadata_Error as the provided ProviderAuthError
  690. func (t *MessageInfo_Metadata_Error) FromProviderAuthError(v ProviderAuthError) error {
  691. v.Name = "ProviderAuthError"
  692. b, err := json.Marshal(v)
  693. t.union = b
  694. return err
  695. }
  696. // MergeProviderAuthError performs a merge with any union data inside the MessageInfo_Metadata_Error, using the provided ProviderAuthError
  697. func (t *MessageInfo_Metadata_Error) MergeProviderAuthError(v ProviderAuthError) error {
  698. v.Name = "ProviderAuthError"
  699. b, err := json.Marshal(v)
  700. if err != nil {
  701. return err
  702. }
  703. merged, err := runtime.JSONMerge(t.union, b)
  704. t.union = merged
  705. return err
  706. }
  707. // AsUnknownError returns the union data inside the MessageInfo_Metadata_Error as a UnknownError
  708. func (t MessageInfo_Metadata_Error) AsUnknownError() (UnknownError, error) {
  709. var body UnknownError
  710. err := json.Unmarshal(t.union, &body)
  711. return body, err
  712. }
  713. // FromUnknownError overwrites any union data inside the MessageInfo_Metadata_Error as the provided UnknownError
  714. func (t *MessageInfo_Metadata_Error) FromUnknownError(v UnknownError) error {
  715. v.Name = "UnknownError"
  716. b, err := json.Marshal(v)
  717. t.union = b
  718. return err
  719. }
  720. // MergeUnknownError performs a merge with any union data inside the MessageInfo_Metadata_Error, using the provided UnknownError
  721. func (t *MessageInfo_Metadata_Error) MergeUnknownError(v UnknownError) error {
  722. v.Name = "UnknownError"
  723. b, err := json.Marshal(v)
  724. if err != nil {
  725. return err
  726. }
  727. merged, err := runtime.JSONMerge(t.union, b)
  728. t.union = merged
  729. return err
  730. }
  731. func (t MessageInfo_Metadata_Error) Discriminator() (string, error) {
  732. var discriminator struct {
  733. Discriminator string `json:"name"`
  734. }
  735. err := json.Unmarshal(t.union, &discriminator)
  736. return discriminator.Discriminator, err
  737. }
  738. func (t MessageInfo_Metadata_Error) ValueByDiscriminator() (interface{}, error) {
  739. discriminator, err := t.Discriminator()
  740. if err != nil {
  741. return nil, err
  742. }
  743. switch discriminator {
  744. case "ProviderAuthError":
  745. return t.AsProviderAuthError()
  746. case "UnknownError":
  747. return t.AsUnknownError()
  748. default:
  749. return nil, errors.New("unknown discriminator value: " + discriminator)
  750. }
  751. }
  752. func (t MessageInfo_Metadata_Error) MarshalJSON() ([]byte, error) {
  753. b, err := t.union.MarshalJSON()
  754. return b, err
  755. }
  756. func (t *MessageInfo_Metadata_Error) UnmarshalJSON(b []byte) error {
  757. err := t.union.UnmarshalJSON(b)
  758. return err
  759. }
  760. // AsMessagePartText returns the union data inside the MessagePart as a MessagePartText
  761. func (t MessagePart) AsMessagePartText() (MessagePartText, error) {
  762. var body MessagePartText
  763. err := json.Unmarshal(t.union, &body)
  764. return body, err
  765. }
  766. // FromMessagePartText overwrites any union data inside the MessagePart as the provided MessagePartText
  767. func (t *MessagePart) FromMessagePartText(v MessagePartText) error {
  768. v.Type = "text"
  769. b, err := json.Marshal(v)
  770. t.union = b
  771. return err
  772. }
  773. // MergeMessagePartText performs a merge with any union data inside the MessagePart, using the provided MessagePartText
  774. func (t *MessagePart) MergeMessagePartText(v MessagePartText) error {
  775. v.Type = "text"
  776. b, err := json.Marshal(v)
  777. if err != nil {
  778. return err
  779. }
  780. merged, err := runtime.JSONMerge(t.union, b)
  781. t.union = merged
  782. return err
  783. }
  784. // AsMessagePartReasoning returns the union data inside the MessagePart as a MessagePartReasoning
  785. func (t MessagePart) AsMessagePartReasoning() (MessagePartReasoning, error) {
  786. var body MessagePartReasoning
  787. err := json.Unmarshal(t.union, &body)
  788. return body, err
  789. }
  790. // FromMessagePartReasoning overwrites any union data inside the MessagePart as the provided MessagePartReasoning
  791. func (t *MessagePart) FromMessagePartReasoning(v MessagePartReasoning) error {
  792. v.Type = "reasoning"
  793. b, err := json.Marshal(v)
  794. t.union = b
  795. return err
  796. }
  797. // MergeMessagePartReasoning performs a merge with any union data inside the MessagePart, using the provided MessagePartReasoning
  798. func (t *MessagePart) MergeMessagePartReasoning(v MessagePartReasoning) error {
  799. v.Type = "reasoning"
  800. b, err := json.Marshal(v)
  801. if err != nil {
  802. return err
  803. }
  804. merged, err := runtime.JSONMerge(t.union, b)
  805. t.union = merged
  806. return err
  807. }
  808. // AsMessagePartToolInvocation returns the union data inside the MessagePart as a MessagePartToolInvocation
  809. func (t MessagePart) AsMessagePartToolInvocation() (MessagePartToolInvocation, error) {
  810. var body MessagePartToolInvocation
  811. err := json.Unmarshal(t.union, &body)
  812. return body, err
  813. }
  814. // FromMessagePartToolInvocation overwrites any union data inside the MessagePart as the provided MessagePartToolInvocation
  815. func (t *MessagePart) FromMessagePartToolInvocation(v MessagePartToolInvocation) error {
  816. v.Type = "tool-invocation"
  817. b, err := json.Marshal(v)
  818. t.union = b
  819. return err
  820. }
  821. // MergeMessagePartToolInvocation performs a merge with any union data inside the MessagePart, using the provided MessagePartToolInvocation
  822. func (t *MessagePart) MergeMessagePartToolInvocation(v MessagePartToolInvocation) error {
  823. v.Type = "tool-invocation"
  824. b, err := json.Marshal(v)
  825. if err != nil {
  826. return err
  827. }
  828. merged, err := runtime.JSONMerge(t.union, b)
  829. t.union = merged
  830. return err
  831. }
  832. // AsMessagePartSourceUrl returns the union data inside the MessagePart as a MessagePartSourceUrl
  833. func (t MessagePart) AsMessagePartSourceUrl() (MessagePartSourceUrl, error) {
  834. var body MessagePartSourceUrl
  835. err := json.Unmarshal(t.union, &body)
  836. return body, err
  837. }
  838. // FromMessagePartSourceUrl overwrites any union data inside the MessagePart as the provided MessagePartSourceUrl
  839. func (t *MessagePart) FromMessagePartSourceUrl(v MessagePartSourceUrl) error {
  840. v.Type = "source-url"
  841. b, err := json.Marshal(v)
  842. t.union = b
  843. return err
  844. }
  845. // MergeMessagePartSourceUrl performs a merge with any union data inside the MessagePart, using the provided MessagePartSourceUrl
  846. func (t *MessagePart) MergeMessagePartSourceUrl(v MessagePartSourceUrl) error {
  847. v.Type = "source-url"
  848. b, err := json.Marshal(v)
  849. if err != nil {
  850. return err
  851. }
  852. merged, err := runtime.JSONMerge(t.union, b)
  853. t.union = merged
  854. return err
  855. }
  856. // AsMessagePartFile returns the union data inside the MessagePart as a MessagePartFile
  857. func (t MessagePart) AsMessagePartFile() (MessagePartFile, error) {
  858. var body MessagePartFile
  859. err := json.Unmarshal(t.union, &body)
  860. return body, err
  861. }
  862. // FromMessagePartFile overwrites any union data inside the MessagePart as the provided MessagePartFile
  863. func (t *MessagePart) FromMessagePartFile(v MessagePartFile) error {
  864. v.Type = "file"
  865. b, err := json.Marshal(v)
  866. t.union = b
  867. return err
  868. }
  869. // MergeMessagePartFile performs a merge with any union data inside the MessagePart, using the provided MessagePartFile
  870. func (t *MessagePart) MergeMessagePartFile(v MessagePartFile) error {
  871. v.Type = "file"
  872. b, err := json.Marshal(v)
  873. if err != nil {
  874. return err
  875. }
  876. merged, err := runtime.JSONMerge(t.union, b)
  877. t.union = merged
  878. return err
  879. }
  880. // AsMessagePartStepStart returns the union data inside the MessagePart as a MessagePartStepStart
  881. func (t MessagePart) AsMessagePartStepStart() (MessagePartStepStart, error) {
  882. var body MessagePartStepStart
  883. err := json.Unmarshal(t.union, &body)
  884. return body, err
  885. }
  886. // FromMessagePartStepStart overwrites any union data inside the MessagePart as the provided MessagePartStepStart
  887. func (t *MessagePart) FromMessagePartStepStart(v MessagePartStepStart) error {
  888. v.Type = "step-start"
  889. b, err := json.Marshal(v)
  890. t.union = b
  891. return err
  892. }
  893. // MergeMessagePartStepStart performs a merge with any union data inside the MessagePart, using the provided MessagePartStepStart
  894. func (t *MessagePart) MergeMessagePartStepStart(v MessagePartStepStart) error {
  895. v.Type = "step-start"
  896. b, err := json.Marshal(v)
  897. if err != nil {
  898. return err
  899. }
  900. merged, err := runtime.JSONMerge(t.union, b)
  901. t.union = merged
  902. return err
  903. }
  904. func (t MessagePart) Discriminator() (string, error) {
  905. var discriminator struct {
  906. Discriminator string `json:"type"`
  907. }
  908. err := json.Unmarshal(t.union, &discriminator)
  909. return discriminator.Discriminator, err
  910. }
  911. func (t MessagePart) ValueByDiscriminator() (interface{}, error) {
  912. discriminator, err := t.Discriminator()
  913. if err != nil {
  914. return nil, err
  915. }
  916. switch discriminator {
  917. case "file":
  918. return t.AsMessagePartFile()
  919. case "reasoning":
  920. return t.AsMessagePartReasoning()
  921. case "source-url":
  922. return t.AsMessagePartSourceUrl()
  923. case "step-start":
  924. return t.AsMessagePartStepStart()
  925. case "text":
  926. return t.AsMessagePartText()
  927. case "tool-invocation":
  928. return t.AsMessagePartToolInvocation()
  929. default:
  930. return nil, errors.New("unknown discriminator value: " + discriminator)
  931. }
  932. }
  933. func (t MessagePart) MarshalJSON() ([]byte, error) {
  934. b, err := t.union.MarshalJSON()
  935. return b, err
  936. }
  937. func (t *MessagePart) UnmarshalJSON(b []byte) error {
  938. err := t.union.UnmarshalJSON(b)
  939. return err
  940. }
  941. // AsMessageToolInvocationToolCall returns the union data inside the MessageToolInvocation as a MessageToolInvocationToolCall
  942. func (t MessageToolInvocation) AsMessageToolInvocationToolCall() (MessageToolInvocationToolCall, error) {
  943. var body MessageToolInvocationToolCall
  944. err := json.Unmarshal(t.union, &body)
  945. return body, err
  946. }
  947. // FromMessageToolInvocationToolCall overwrites any union data inside the MessageToolInvocation as the provided MessageToolInvocationToolCall
  948. func (t *MessageToolInvocation) FromMessageToolInvocationToolCall(v MessageToolInvocationToolCall) error {
  949. v.State = "call"
  950. b, err := json.Marshal(v)
  951. t.union = b
  952. return err
  953. }
  954. // MergeMessageToolInvocationToolCall performs a merge with any union data inside the MessageToolInvocation, using the provided MessageToolInvocationToolCall
  955. func (t *MessageToolInvocation) MergeMessageToolInvocationToolCall(v MessageToolInvocationToolCall) error {
  956. v.State = "call"
  957. b, err := json.Marshal(v)
  958. if err != nil {
  959. return err
  960. }
  961. merged, err := runtime.JSONMerge(t.union, b)
  962. t.union = merged
  963. return err
  964. }
  965. // AsMessageToolInvocationToolPartialCall returns the union data inside the MessageToolInvocation as a MessageToolInvocationToolPartialCall
  966. func (t MessageToolInvocation) AsMessageToolInvocationToolPartialCall() (MessageToolInvocationToolPartialCall, error) {
  967. var body MessageToolInvocationToolPartialCall
  968. err := json.Unmarshal(t.union, &body)
  969. return body, err
  970. }
  971. // FromMessageToolInvocationToolPartialCall overwrites any union data inside the MessageToolInvocation as the provided MessageToolInvocationToolPartialCall
  972. func (t *MessageToolInvocation) FromMessageToolInvocationToolPartialCall(v MessageToolInvocationToolPartialCall) error {
  973. v.State = "partial-call"
  974. b, err := json.Marshal(v)
  975. t.union = b
  976. return err
  977. }
  978. // MergeMessageToolInvocationToolPartialCall performs a merge with any union data inside the MessageToolInvocation, using the provided MessageToolInvocationToolPartialCall
  979. func (t *MessageToolInvocation) MergeMessageToolInvocationToolPartialCall(v MessageToolInvocationToolPartialCall) error {
  980. v.State = "partial-call"
  981. b, err := json.Marshal(v)
  982. if err != nil {
  983. return err
  984. }
  985. merged, err := runtime.JSONMerge(t.union, b)
  986. t.union = merged
  987. return err
  988. }
  989. // AsMessageToolInvocationToolResult returns the union data inside the MessageToolInvocation as a MessageToolInvocationToolResult
  990. func (t MessageToolInvocation) AsMessageToolInvocationToolResult() (MessageToolInvocationToolResult, error) {
  991. var body MessageToolInvocationToolResult
  992. err := json.Unmarshal(t.union, &body)
  993. return body, err
  994. }
  995. // FromMessageToolInvocationToolResult overwrites any union data inside the MessageToolInvocation as the provided MessageToolInvocationToolResult
  996. func (t *MessageToolInvocation) FromMessageToolInvocationToolResult(v MessageToolInvocationToolResult) error {
  997. v.State = "result"
  998. b, err := json.Marshal(v)
  999. t.union = b
  1000. return err
  1001. }
  1002. // MergeMessageToolInvocationToolResult performs a merge with any union data inside the MessageToolInvocation, using the provided MessageToolInvocationToolResult
  1003. func (t *MessageToolInvocation) MergeMessageToolInvocationToolResult(v MessageToolInvocationToolResult) error {
  1004. v.State = "result"
  1005. b, err := json.Marshal(v)
  1006. if err != nil {
  1007. return err
  1008. }
  1009. merged, err := runtime.JSONMerge(t.union, b)
  1010. t.union = merged
  1011. return err
  1012. }
  1013. func (t MessageToolInvocation) Discriminator() (string, error) {
  1014. var discriminator struct {
  1015. Discriminator string `json:"state"`
  1016. }
  1017. err := json.Unmarshal(t.union, &discriminator)
  1018. return discriminator.Discriminator, err
  1019. }
  1020. func (t MessageToolInvocation) ValueByDiscriminator() (interface{}, error) {
  1021. discriminator, err := t.Discriminator()
  1022. if err != nil {
  1023. return nil, err
  1024. }
  1025. switch discriminator {
  1026. case "call":
  1027. return t.AsMessageToolInvocationToolCall()
  1028. case "partial-call":
  1029. return t.AsMessageToolInvocationToolPartialCall()
  1030. case "result":
  1031. return t.AsMessageToolInvocationToolResult()
  1032. default:
  1033. return nil, errors.New("unknown discriminator value: " + discriminator)
  1034. }
  1035. }
  1036. func (t MessageToolInvocation) MarshalJSON() ([]byte, error) {
  1037. b, err := t.union.MarshalJSON()
  1038. return b, err
  1039. }
  1040. func (t *MessageToolInvocation) UnmarshalJSON(b []byte) error {
  1041. err := t.union.UnmarshalJSON(b)
  1042. return err
  1043. }
  1044. // RequestEditorFn is the function signature for the RequestEditor callback function
  1045. type RequestEditorFn func(ctx context.Context, req *http.Request) error
  1046. // Doer performs HTTP requests.
  1047. //
  1048. // The standard http.Client implements this interface.
  1049. type HttpRequestDoer interface {
  1050. Do(req *http.Request) (*http.Response, error)
  1051. }
  1052. // Client which conforms to the OpenAPI3 specification for this service.
  1053. type Client struct {
  1054. // The endpoint of the server conforming to this interface, with scheme,
  1055. // https://api.deepmap.com for example. This can contain a path relative
  1056. // to the server, such as https://api.deepmap.com/dev-test, and all the
  1057. // paths in the swagger spec will be appended to the server.
  1058. Server string
  1059. // Doer for performing requests, typically a *http.Client with any
  1060. // customized settings, such as certificate chains.
  1061. Client HttpRequestDoer
  1062. // A list of callbacks for modifying requests which are generated before sending over
  1063. // the network.
  1064. RequestEditors []RequestEditorFn
  1065. }
  1066. // ClientOption allows setting custom parameters during construction
  1067. type ClientOption func(*Client) error
  1068. // Creates a new Client, with reasonable defaults
  1069. func NewClient(server string, opts ...ClientOption) (*Client, error) {
  1070. // create a client with sane default values
  1071. client := Client{
  1072. Server: server,
  1073. }
  1074. // mutate client and add all optional params
  1075. for _, o := range opts {
  1076. if err := o(&client); err != nil {
  1077. return nil, err
  1078. }
  1079. }
  1080. // ensure the server URL always has a trailing slash
  1081. if !strings.HasSuffix(client.Server, "/") {
  1082. client.Server += "/"
  1083. }
  1084. // create httpClient, if not already present
  1085. if client.Client == nil {
  1086. client.Client = &http.Client{}
  1087. }
  1088. return &client, nil
  1089. }
  1090. // WithHTTPClient allows overriding the default Doer, which is
  1091. // automatically created using http.Client. This is useful for tests.
  1092. func WithHTTPClient(doer HttpRequestDoer) ClientOption {
  1093. return func(c *Client) error {
  1094. c.Client = doer
  1095. return nil
  1096. }
  1097. }
  1098. // WithRequestEditorFn allows setting up a callback function, which will be
  1099. // called right before sending the request. This can be used to mutate the request.
  1100. func WithRequestEditorFn(fn RequestEditorFn) ClientOption {
  1101. return func(c *Client) error {
  1102. c.RequestEditors = append(c.RequestEditors, fn)
  1103. return nil
  1104. }
  1105. }
  1106. // The interface specification for the client above.
  1107. type ClientInterface interface {
  1108. // PostAppInfo request
  1109. PostAppInfo(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error)
  1110. // PostAppInitialize request
  1111. PostAppInitialize(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error)
  1112. // GetEvent request
  1113. GetEvent(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error)
  1114. // PostFileSearchWithBody request with any body
  1115. PostFileSearchWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error)
  1116. PostFileSearch(ctx context.Context, body PostFileSearchJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error)
  1117. // PostPathGet request
  1118. PostPathGet(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error)
  1119. // PostProviderList request
  1120. PostProviderList(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error)
  1121. // PostSessionAbortWithBody request with any body
  1122. PostSessionAbortWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error)
  1123. PostSessionAbort(ctx context.Context, body PostSessionAbortJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error)
  1124. // PostSessionChatWithBody request with any body
  1125. PostSessionChatWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error)
  1126. PostSessionChat(ctx context.Context, body PostSessionChatJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error)
  1127. // PostSessionCreate request
  1128. PostSessionCreate(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error)
  1129. // PostSessionInitializeWithBody request with any body
  1130. PostSessionInitializeWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error)
  1131. PostSessionInitialize(ctx context.Context, body PostSessionInitializeJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error)
  1132. // PostSessionList request
  1133. PostSessionList(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error)
  1134. // PostSessionMessagesWithBody request with any body
  1135. PostSessionMessagesWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error)
  1136. PostSessionMessages(ctx context.Context, body PostSessionMessagesJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error)
  1137. // PostSessionShareWithBody request with any body
  1138. PostSessionShareWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error)
  1139. PostSessionShare(ctx context.Context, body PostSessionShareJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error)
  1140. // PostSessionSummarizeWithBody request with any body
  1141. PostSessionSummarizeWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error)
  1142. PostSessionSummarize(ctx context.Context, body PostSessionSummarizeJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error)
  1143. }
  1144. func (c *Client) PostAppInfo(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error) {
  1145. req, err := NewPostAppInfoRequest(c.Server)
  1146. if err != nil {
  1147. return nil, err
  1148. }
  1149. req = req.WithContext(ctx)
  1150. if err := c.applyEditors(ctx, req, reqEditors); err != nil {
  1151. return nil, err
  1152. }
  1153. return c.Client.Do(req)
  1154. }
  1155. func (c *Client) PostAppInitialize(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error) {
  1156. req, err := NewPostAppInitializeRequest(c.Server)
  1157. if err != nil {
  1158. return nil, err
  1159. }
  1160. req = req.WithContext(ctx)
  1161. if err := c.applyEditors(ctx, req, reqEditors); err != nil {
  1162. return nil, err
  1163. }
  1164. return c.Client.Do(req)
  1165. }
  1166. func (c *Client) GetEvent(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error) {
  1167. req, err := NewGetEventRequest(c.Server)
  1168. if err != nil {
  1169. return nil, err
  1170. }
  1171. req = req.WithContext(ctx)
  1172. if err := c.applyEditors(ctx, req, reqEditors); err != nil {
  1173. return nil, err
  1174. }
  1175. return c.Client.Do(req)
  1176. }
  1177. func (c *Client) PostFileSearchWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) {
  1178. req, err := NewPostFileSearchRequestWithBody(c.Server, contentType, body)
  1179. if err != nil {
  1180. return nil, err
  1181. }
  1182. req = req.WithContext(ctx)
  1183. if err := c.applyEditors(ctx, req, reqEditors); err != nil {
  1184. return nil, err
  1185. }
  1186. return c.Client.Do(req)
  1187. }
  1188. func (c *Client) PostFileSearch(ctx context.Context, body PostFileSearchJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) {
  1189. req, err := NewPostFileSearchRequest(c.Server, body)
  1190. if err != nil {
  1191. return nil, err
  1192. }
  1193. req = req.WithContext(ctx)
  1194. if err := c.applyEditors(ctx, req, reqEditors); err != nil {
  1195. return nil, err
  1196. }
  1197. return c.Client.Do(req)
  1198. }
  1199. func (c *Client) PostPathGet(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error) {
  1200. req, err := NewPostPathGetRequest(c.Server)
  1201. if err != nil {
  1202. return nil, err
  1203. }
  1204. req = req.WithContext(ctx)
  1205. if err := c.applyEditors(ctx, req, reqEditors); err != nil {
  1206. return nil, err
  1207. }
  1208. return c.Client.Do(req)
  1209. }
  1210. func (c *Client) PostProviderList(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error) {
  1211. req, err := NewPostProviderListRequest(c.Server)
  1212. if err != nil {
  1213. return nil, err
  1214. }
  1215. req = req.WithContext(ctx)
  1216. if err := c.applyEditors(ctx, req, reqEditors); err != nil {
  1217. return nil, err
  1218. }
  1219. return c.Client.Do(req)
  1220. }
  1221. func (c *Client) PostSessionAbortWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) {
  1222. req, err := NewPostSessionAbortRequestWithBody(c.Server, contentType, body)
  1223. if err != nil {
  1224. return nil, err
  1225. }
  1226. req = req.WithContext(ctx)
  1227. if err := c.applyEditors(ctx, req, reqEditors); err != nil {
  1228. return nil, err
  1229. }
  1230. return c.Client.Do(req)
  1231. }
  1232. func (c *Client) PostSessionAbort(ctx context.Context, body PostSessionAbortJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) {
  1233. req, err := NewPostSessionAbortRequest(c.Server, body)
  1234. if err != nil {
  1235. return nil, err
  1236. }
  1237. req = req.WithContext(ctx)
  1238. if err := c.applyEditors(ctx, req, reqEditors); err != nil {
  1239. return nil, err
  1240. }
  1241. return c.Client.Do(req)
  1242. }
  1243. func (c *Client) PostSessionChatWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) {
  1244. req, err := NewPostSessionChatRequestWithBody(c.Server, contentType, body)
  1245. if err != nil {
  1246. return nil, err
  1247. }
  1248. req = req.WithContext(ctx)
  1249. if err := c.applyEditors(ctx, req, reqEditors); err != nil {
  1250. return nil, err
  1251. }
  1252. return c.Client.Do(req)
  1253. }
  1254. func (c *Client) PostSessionChat(ctx context.Context, body PostSessionChatJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) {
  1255. req, err := NewPostSessionChatRequest(c.Server, body)
  1256. if err != nil {
  1257. return nil, err
  1258. }
  1259. req = req.WithContext(ctx)
  1260. if err := c.applyEditors(ctx, req, reqEditors); err != nil {
  1261. return nil, err
  1262. }
  1263. return c.Client.Do(req)
  1264. }
  1265. func (c *Client) PostSessionCreate(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error) {
  1266. req, err := NewPostSessionCreateRequest(c.Server)
  1267. if err != nil {
  1268. return nil, err
  1269. }
  1270. req = req.WithContext(ctx)
  1271. if err := c.applyEditors(ctx, req, reqEditors); err != nil {
  1272. return nil, err
  1273. }
  1274. return c.Client.Do(req)
  1275. }
  1276. func (c *Client) PostSessionInitializeWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) {
  1277. req, err := NewPostSessionInitializeRequestWithBody(c.Server, contentType, body)
  1278. if err != nil {
  1279. return nil, err
  1280. }
  1281. req = req.WithContext(ctx)
  1282. if err := c.applyEditors(ctx, req, reqEditors); err != nil {
  1283. return nil, err
  1284. }
  1285. return c.Client.Do(req)
  1286. }
  1287. func (c *Client) PostSessionInitialize(ctx context.Context, body PostSessionInitializeJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) {
  1288. req, err := NewPostSessionInitializeRequest(c.Server, body)
  1289. if err != nil {
  1290. return nil, err
  1291. }
  1292. req = req.WithContext(ctx)
  1293. if err := c.applyEditors(ctx, req, reqEditors); err != nil {
  1294. return nil, err
  1295. }
  1296. return c.Client.Do(req)
  1297. }
  1298. func (c *Client) PostSessionList(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error) {
  1299. req, err := NewPostSessionListRequest(c.Server)
  1300. if err != nil {
  1301. return nil, err
  1302. }
  1303. req = req.WithContext(ctx)
  1304. if err := c.applyEditors(ctx, req, reqEditors); err != nil {
  1305. return nil, err
  1306. }
  1307. return c.Client.Do(req)
  1308. }
  1309. func (c *Client) PostSessionMessagesWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) {
  1310. req, err := NewPostSessionMessagesRequestWithBody(c.Server, contentType, body)
  1311. if err != nil {
  1312. return nil, err
  1313. }
  1314. req = req.WithContext(ctx)
  1315. if err := c.applyEditors(ctx, req, reqEditors); err != nil {
  1316. return nil, err
  1317. }
  1318. return c.Client.Do(req)
  1319. }
  1320. func (c *Client) PostSessionMessages(ctx context.Context, body PostSessionMessagesJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) {
  1321. req, err := NewPostSessionMessagesRequest(c.Server, body)
  1322. if err != nil {
  1323. return nil, err
  1324. }
  1325. req = req.WithContext(ctx)
  1326. if err := c.applyEditors(ctx, req, reqEditors); err != nil {
  1327. return nil, err
  1328. }
  1329. return c.Client.Do(req)
  1330. }
  1331. func (c *Client) PostSessionShareWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) {
  1332. req, err := NewPostSessionShareRequestWithBody(c.Server, contentType, body)
  1333. if err != nil {
  1334. return nil, err
  1335. }
  1336. req = req.WithContext(ctx)
  1337. if err := c.applyEditors(ctx, req, reqEditors); err != nil {
  1338. return nil, err
  1339. }
  1340. return c.Client.Do(req)
  1341. }
  1342. func (c *Client) PostSessionShare(ctx context.Context, body PostSessionShareJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) {
  1343. req, err := NewPostSessionShareRequest(c.Server, body)
  1344. if err != nil {
  1345. return nil, err
  1346. }
  1347. req = req.WithContext(ctx)
  1348. if err := c.applyEditors(ctx, req, reqEditors); err != nil {
  1349. return nil, err
  1350. }
  1351. return c.Client.Do(req)
  1352. }
  1353. func (c *Client) PostSessionSummarizeWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) {
  1354. req, err := NewPostSessionSummarizeRequestWithBody(c.Server, contentType, body)
  1355. if err != nil {
  1356. return nil, err
  1357. }
  1358. req = req.WithContext(ctx)
  1359. if err := c.applyEditors(ctx, req, reqEditors); err != nil {
  1360. return nil, err
  1361. }
  1362. return c.Client.Do(req)
  1363. }
  1364. func (c *Client) PostSessionSummarize(ctx context.Context, body PostSessionSummarizeJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) {
  1365. req, err := NewPostSessionSummarizeRequest(c.Server, body)
  1366. if err != nil {
  1367. return nil, err
  1368. }
  1369. req = req.WithContext(ctx)
  1370. if err := c.applyEditors(ctx, req, reqEditors); err != nil {
  1371. return nil, err
  1372. }
  1373. return c.Client.Do(req)
  1374. }
  1375. // NewPostAppInfoRequest generates requests for PostAppInfo
  1376. func NewPostAppInfoRequest(server string) (*http.Request, error) {
  1377. var err error
  1378. serverURL, err := url.Parse(server)
  1379. if err != nil {
  1380. return nil, err
  1381. }
  1382. operationPath := fmt.Sprintf("/app_info")
  1383. if operationPath[0] == '/' {
  1384. operationPath = "." + operationPath
  1385. }
  1386. queryURL, err := serverURL.Parse(operationPath)
  1387. if err != nil {
  1388. return nil, err
  1389. }
  1390. req, err := http.NewRequest("POST", queryURL.String(), nil)
  1391. if err != nil {
  1392. return nil, err
  1393. }
  1394. return req, nil
  1395. }
  1396. // NewPostAppInitializeRequest generates requests for PostAppInitialize
  1397. func NewPostAppInitializeRequest(server string) (*http.Request, error) {
  1398. var err error
  1399. serverURL, err := url.Parse(server)
  1400. if err != nil {
  1401. return nil, err
  1402. }
  1403. operationPath := fmt.Sprintf("/app_initialize")
  1404. if operationPath[0] == '/' {
  1405. operationPath = "." + operationPath
  1406. }
  1407. queryURL, err := serverURL.Parse(operationPath)
  1408. if err != nil {
  1409. return nil, err
  1410. }
  1411. req, err := http.NewRequest("POST", queryURL.String(), nil)
  1412. if err != nil {
  1413. return nil, err
  1414. }
  1415. return req, nil
  1416. }
  1417. // NewGetEventRequest generates requests for GetEvent
  1418. func NewGetEventRequest(server string) (*http.Request, error) {
  1419. var err error
  1420. serverURL, err := url.Parse(server)
  1421. if err != nil {
  1422. return nil, err
  1423. }
  1424. operationPath := fmt.Sprintf("/event")
  1425. if operationPath[0] == '/' {
  1426. operationPath = "." + operationPath
  1427. }
  1428. queryURL, err := serverURL.Parse(operationPath)
  1429. if err != nil {
  1430. return nil, err
  1431. }
  1432. req, err := http.NewRequest("GET", queryURL.String(), nil)
  1433. if err != nil {
  1434. return nil, err
  1435. }
  1436. return req, nil
  1437. }
  1438. // NewPostFileSearchRequest calls the generic PostFileSearch builder with application/json body
  1439. func NewPostFileSearchRequest(server string, body PostFileSearchJSONRequestBody) (*http.Request, error) {
  1440. var bodyReader io.Reader
  1441. buf, err := json.Marshal(body)
  1442. if err != nil {
  1443. return nil, err
  1444. }
  1445. bodyReader = bytes.NewReader(buf)
  1446. return NewPostFileSearchRequestWithBody(server, "application/json", bodyReader)
  1447. }
  1448. // NewPostFileSearchRequestWithBody generates requests for PostFileSearch with any type of body
  1449. func NewPostFileSearchRequestWithBody(server string, contentType string, body io.Reader) (*http.Request, error) {
  1450. var err error
  1451. serverURL, err := url.Parse(server)
  1452. if err != nil {
  1453. return nil, err
  1454. }
  1455. operationPath := fmt.Sprintf("/file_search")
  1456. if operationPath[0] == '/' {
  1457. operationPath = "." + operationPath
  1458. }
  1459. queryURL, err := serverURL.Parse(operationPath)
  1460. if err != nil {
  1461. return nil, err
  1462. }
  1463. req, err := http.NewRequest("POST", queryURL.String(), body)
  1464. if err != nil {
  1465. return nil, err
  1466. }
  1467. req.Header.Add("Content-Type", contentType)
  1468. return req, nil
  1469. }
  1470. // NewPostPathGetRequest generates requests for PostPathGet
  1471. func NewPostPathGetRequest(server string) (*http.Request, error) {
  1472. var err error
  1473. serverURL, err := url.Parse(server)
  1474. if err != nil {
  1475. return nil, err
  1476. }
  1477. operationPath := fmt.Sprintf("/path_get")
  1478. if operationPath[0] == '/' {
  1479. operationPath = "." + operationPath
  1480. }
  1481. queryURL, err := serverURL.Parse(operationPath)
  1482. if err != nil {
  1483. return nil, err
  1484. }
  1485. req, err := http.NewRequest("POST", queryURL.String(), nil)
  1486. if err != nil {
  1487. return nil, err
  1488. }
  1489. return req, nil
  1490. }
  1491. // NewPostProviderListRequest generates requests for PostProviderList
  1492. func NewPostProviderListRequest(server string) (*http.Request, error) {
  1493. var err error
  1494. serverURL, err := url.Parse(server)
  1495. if err != nil {
  1496. return nil, err
  1497. }
  1498. operationPath := fmt.Sprintf("/provider_list")
  1499. if operationPath[0] == '/' {
  1500. operationPath = "." + operationPath
  1501. }
  1502. queryURL, err := serverURL.Parse(operationPath)
  1503. if err != nil {
  1504. return nil, err
  1505. }
  1506. req, err := http.NewRequest("POST", queryURL.String(), nil)
  1507. if err != nil {
  1508. return nil, err
  1509. }
  1510. return req, nil
  1511. }
  1512. // NewPostSessionAbortRequest calls the generic PostSessionAbort builder with application/json body
  1513. func NewPostSessionAbortRequest(server string, body PostSessionAbortJSONRequestBody) (*http.Request, error) {
  1514. var bodyReader io.Reader
  1515. buf, err := json.Marshal(body)
  1516. if err != nil {
  1517. return nil, err
  1518. }
  1519. bodyReader = bytes.NewReader(buf)
  1520. return NewPostSessionAbortRequestWithBody(server, "application/json", bodyReader)
  1521. }
  1522. // NewPostSessionAbortRequestWithBody generates requests for PostSessionAbort with any type of body
  1523. func NewPostSessionAbortRequestWithBody(server string, contentType string, body io.Reader) (*http.Request, error) {
  1524. var err error
  1525. serverURL, err := url.Parse(server)
  1526. if err != nil {
  1527. return nil, err
  1528. }
  1529. operationPath := fmt.Sprintf("/session_abort")
  1530. if operationPath[0] == '/' {
  1531. operationPath = "." + operationPath
  1532. }
  1533. queryURL, err := serverURL.Parse(operationPath)
  1534. if err != nil {
  1535. return nil, err
  1536. }
  1537. req, err := http.NewRequest("POST", queryURL.String(), body)
  1538. if err != nil {
  1539. return nil, err
  1540. }
  1541. req.Header.Add("Content-Type", contentType)
  1542. return req, nil
  1543. }
  1544. // NewPostSessionChatRequest calls the generic PostSessionChat builder with application/json body
  1545. func NewPostSessionChatRequest(server string, body PostSessionChatJSONRequestBody) (*http.Request, error) {
  1546. var bodyReader io.Reader
  1547. buf, err := json.Marshal(body)
  1548. if err != nil {
  1549. return nil, err
  1550. }
  1551. bodyReader = bytes.NewReader(buf)
  1552. return NewPostSessionChatRequestWithBody(server, "application/json", bodyReader)
  1553. }
  1554. // NewPostSessionChatRequestWithBody generates requests for PostSessionChat with any type of body
  1555. func NewPostSessionChatRequestWithBody(server string, contentType string, body io.Reader) (*http.Request, error) {
  1556. var err error
  1557. serverURL, err := url.Parse(server)
  1558. if err != nil {
  1559. return nil, err
  1560. }
  1561. operationPath := fmt.Sprintf("/session_chat")
  1562. if operationPath[0] == '/' {
  1563. operationPath = "." + operationPath
  1564. }
  1565. queryURL, err := serverURL.Parse(operationPath)
  1566. if err != nil {
  1567. return nil, err
  1568. }
  1569. req, err := http.NewRequest("POST", queryURL.String(), body)
  1570. if err != nil {
  1571. return nil, err
  1572. }
  1573. req.Header.Add("Content-Type", contentType)
  1574. return req, nil
  1575. }
  1576. // NewPostSessionCreateRequest generates requests for PostSessionCreate
  1577. func NewPostSessionCreateRequest(server string) (*http.Request, error) {
  1578. var err error
  1579. serverURL, err := url.Parse(server)
  1580. if err != nil {
  1581. return nil, err
  1582. }
  1583. operationPath := fmt.Sprintf("/session_create")
  1584. if operationPath[0] == '/' {
  1585. operationPath = "." + operationPath
  1586. }
  1587. queryURL, err := serverURL.Parse(operationPath)
  1588. if err != nil {
  1589. return nil, err
  1590. }
  1591. req, err := http.NewRequest("POST", queryURL.String(), nil)
  1592. if err != nil {
  1593. return nil, err
  1594. }
  1595. return req, nil
  1596. }
  1597. // NewPostSessionInitializeRequest calls the generic PostSessionInitialize builder with application/json body
  1598. func NewPostSessionInitializeRequest(server string, body PostSessionInitializeJSONRequestBody) (*http.Request, error) {
  1599. var bodyReader io.Reader
  1600. buf, err := json.Marshal(body)
  1601. if err != nil {
  1602. return nil, err
  1603. }
  1604. bodyReader = bytes.NewReader(buf)
  1605. return NewPostSessionInitializeRequestWithBody(server, "application/json", bodyReader)
  1606. }
  1607. // NewPostSessionInitializeRequestWithBody generates requests for PostSessionInitialize with any type of body
  1608. func NewPostSessionInitializeRequestWithBody(server string, contentType string, body io.Reader) (*http.Request, error) {
  1609. var err error
  1610. serverURL, err := url.Parse(server)
  1611. if err != nil {
  1612. return nil, err
  1613. }
  1614. operationPath := fmt.Sprintf("/session_initialize")
  1615. if operationPath[0] == '/' {
  1616. operationPath = "." + operationPath
  1617. }
  1618. queryURL, err := serverURL.Parse(operationPath)
  1619. if err != nil {
  1620. return nil, err
  1621. }
  1622. req, err := http.NewRequest("POST", queryURL.String(), body)
  1623. if err != nil {
  1624. return nil, err
  1625. }
  1626. req.Header.Add("Content-Type", contentType)
  1627. return req, nil
  1628. }
  1629. // NewPostSessionListRequest generates requests for PostSessionList
  1630. func NewPostSessionListRequest(server string) (*http.Request, error) {
  1631. var err error
  1632. serverURL, err := url.Parse(server)
  1633. if err != nil {
  1634. return nil, err
  1635. }
  1636. operationPath := fmt.Sprintf("/session_list")
  1637. if operationPath[0] == '/' {
  1638. operationPath = "." + operationPath
  1639. }
  1640. queryURL, err := serverURL.Parse(operationPath)
  1641. if err != nil {
  1642. return nil, err
  1643. }
  1644. req, err := http.NewRequest("POST", queryURL.String(), nil)
  1645. if err != nil {
  1646. return nil, err
  1647. }
  1648. return req, nil
  1649. }
  1650. // NewPostSessionMessagesRequest calls the generic PostSessionMessages builder with application/json body
  1651. func NewPostSessionMessagesRequest(server string, body PostSessionMessagesJSONRequestBody) (*http.Request, error) {
  1652. var bodyReader io.Reader
  1653. buf, err := json.Marshal(body)
  1654. if err != nil {
  1655. return nil, err
  1656. }
  1657. bodyReader = bytes.NewReader(buf)
  1658. return NewPostSessionMessagesRequestWithBody(server, "application/json", bodyReader)
  1659. }
  1660. // NewPostSessionMessagesRequestWithBody generates requests for PostSessionMessages with any type of body
  1661. func NewPostSessionMessagesRequestWithBody(server string, contentType string, body io.Reader) (*http.Request, error) {
  1662. var err error
  1663. serverURL, err := url.Parse(server)
  1664. if err != nil {
  1665. return nil, err
  1666. }
  1667. operationPath := fmt.Sprintf("/session_messages")
  1668. if operationPath[0] == '/' {
  1669. operationPath = "." + operationPath
  1670. }
  1671. queryURL, err := serverURL.Parse(operationPath)
  1672. if err != nil {
  1673. return nil, err
  1674. }
  1675. req, err := http.NewRequest("POST", queryURL.String(), body)
  1676. if err != nil {
  1677. return nil, err
  1678. }
  1679. req.Header.Add("Content-Type", contentType)
  1680. return req, nil
  1681. }
  1682. // NewPostSessionShareRequest calls the generic PostSessionShare builder with application/json body
  1683. func NewPostSessionShareRequest(server string, body PostSessionShareJSONRequestBody) (*http.Request, error) {
  1684. var bodyReader io.Reader
  1685. buf, err := json.Marshal(body)
  1686. if err != nil {
  1687. return nil, err
  1688. }
  1689. bodyReader = bytes.NewReader(buf)
  1690. return NewPostSessionShareRequestWithBody(server, "application/json", bodyReader)
  1691. }
  1692. // NewPostSessionShareRequestWithBody generates requests for PostSessionShare with any type of body
  1693. func NewPostSessionShareRequestWithBody(server string, contentType string, body io.Reader) (*http.Request, error) {
  1694. var err error
  1695. serverURL, err := url.Parse(server)
  1696. if err != nil {
  1697. return nil, err
  1698. }
  1699. operationPath := fmt.Sprintf("/session_share")
  1700. if operationPath[0] == '/' {
  1701. operationPath = "." + operationPath
  1702. }
  1703. queryURL, err := serverURL.Parse(operationPath)
  1704. if err != nil {
  1705. return nil, err
  1706. }
  1707. req, err := http.NewRequest("POST", queryURL.String(), body)
  1708. if err != nil {
  1709. return nil, err
  1710. }
  1711. req.Header.Add("Content-Type", contentType)
  1712. return req, nil
  1713. }
  1714. // NewPostSessionSummarizeRequest calls the generic PostSessionSummarize builder with application/json body
  1715. func NewPostSessionSummarizeRequest(server string, body PostSessionSummarizeJSONRequestBody) (*http.Request, error) {
  1716. var bodyReader io.Reader
  1717. buf, err := json.Marshal(body)
  1718. if err != nil {
  1719. return nil, err
  1720. }
  1721. bodyReader = bytes.NewReader(buf)
  1722. return NewPostSessionSummarizeRequestWithBody(server, "application/json", bodyReader)
  1723. }
  1724. // NewPostSessionSummarizeRequestWithBody generates requests for PostSessionSummarize with any type of body
  1725. func NewPostSessionSummarizeRequestWithBody(server string, contentType string, body io.Reader) (*http.Request, error) {
  1726. var err error
  1727. serverURL, err := url.Parse(server)
  1728. if err != nil {
  1729. return nil, err
  1730. }
  1731. operationPath := fmt.Sprintf("/session_summarize")
  1732. if operationPath[0] == '/' {
  1733. operationPath = "." + operationPath
  1734. }
  1735. queryURL, err := serverURL.Parse(operationPath)
  1736. if err != nil {
  1737. return nil, err
  1738. }
  1739. req, err := http.NewRequest("POST", queryURL.String(), body)
  1740. if err != nil {
  1741. return nil, err
  1742. }
  1743. req.Header.Add("Content-Type", contentType)
  1744. return req, nil
  1745. }
  1746. func (c *Client) applyEditors(ctx context.Context, req *http.Request, additionalEditors []RequestEditorFn) error {
  1747. for _, r := range c.RequestEditors {
  1748. if err := r(ctx, req); err != nil {
  1749. return err
  1750. }
  1751. }
  1752. for _, r := range additionalEditors {
  1753. if err := r(ctx, req); err != nil {
  1754. return err
  1755. }
  1756. }
  1757. return nil
  1758. }
  1759. // ClientWithResponses builds on ClientInterface to offer response payloads
  1760. type ClientWithResponses struct {
  1761. ClientInterface
  1762. }
  1763. // NewClientWithResponses creates a new ClientWithResponses, which wraps
  1764. // Client with return type handling
  1765. func NewClientWithResponses(server string, opts ...ClientOption) (*ClientWithResponses, error) {
  1766. client, err := NewClient(server, opts...)
  1767. if err != nil {
  1768. return nil, err
  1769. }
  1770. return &ClientWithResponses{client}, nil
  1771. }
  1772. // WithBaseURL overrides the baseURL.
  1773. func WithBaseURL(baseURL string) ClientOption {
  1774. return func(c *Client) error {
  1775. newBaseURL, err := url.Parse(baseURL)
  1776. if err != nil {
  1777. return err
  1778. }
  1779. c.Server = newBaseURL.String()
  1780. return nil
  1781. }
  1782. }
  1783. // ClientWithResponsesInterface is the interface specification for the client with responses above.
  1784. type ClientWithResponsesInterface interface {
  1785. // PostAppInfoWithResponse request
  1786. PostAppInfoWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*PostAppInfoResponse, error)
  1787. // PostAppInitializeWithResponse request
  1788. PostAppInitializeWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*PostAppInitializeResponse, error)
  1789. // GetEventWithResponse request
  1790. GetEventWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*GetEventResponse, error)
  1791. // PostFileSearchWithBodyWithResponse request with any body
  1792. PostFileSearchWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*PostFileSearchResponse, error)
  1793. PostFileSearchWithResponse(ctx context.Context, body PostFileSearchJSONRequestBody, reqEditors ...RequestEditorFn) (*PostFileSearchResponse, error)
  1794. // PostPathGetWithResponse request
  1795. PostPathGetWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*PostPathGetResponse, error)
  1796. // PostProviderListWithResponse request
  1797. PostProviderListWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*PostProviderListResponse, error)
  1798. // PostSessionAbortWithBodyWithResponse request with any body
  1799. PostSessionAbortWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*PostSessionAbortResponse, error)
  1800. PostSessionAbortWithResponse(ctx context.Context, body PostSessionAbortJSONRequestBody, reqEditors ...RequestEditorFn) (*PostSessionAbortResponse, error)
  1801. // PostSessionChatWithBodyWithResponse request with any body
  1802. PostSessionChatWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*PostSessionChatResponse, error)
  1803. PostSessionChatWithResponse(ctx context.Context, body PostSessionChatJSONRequestBody, reqEditors ...RequestEditorFn) (*PostSessionChatResponse, error)
  1804. // PostSessionCreateWithResponse request
  1805. PostSessionCreateWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*PostSessionCreateResponse, error)
  1806. // PostSessionInitializeWithBodyWithResponse request with any body
  1807. PostSessionInitializeWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*PostSessionInitializeResponse, error)
  1808. PostSessionInitializeWithResponse(ctx context.Context, body PostSessionInitializeJSONRequestBody, reqEditors ...RequestEditorFn) (*PostSessionInitializeResponse, error)
  1809. // PostSessionListWithResponse request
  1810. PostSessionListWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*PostSessionListResponse, error)
  1811. // PostSessionMessagesWithBodyWithResponse request with any body
  1812. PostSessionMessagesWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*PostSessionMessagesResponse, error)
  1813. PostSessionMessagesWithResponse(ctx context.Context, body PostSessionMessagesJSONRequestBody, reqEditors ...RequestEditorFn) (*PostSessionMessagesResponse, error)
  1814. // PostSessionShareWithBodyWithResponse request with any body
  1815. PostSessionShareWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*PostSessionShareResponse, error)
  1816. PostSessionShareWithResponse(ctx context.Context, body PostSessionShareJSONRequestBody, reqEditors ...RequestEditorFn) (*PostSessionShareResponse, error)
  1817. // PostSessionSummarizeWithBodyWithResponse request with any body
  1818. PostSessionSummarizeWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*PostSessionSummarizeResponse, error)
  1819. PostSessionSummarizeWithResponse(ctx context.Context, body PostSessionSummarizeJSONRequestBody, reqEditors ...RequestEditorFn) (*PostSessionSummarizeResponse, error)
  1820. }
  1821. type PostAppInfoResponse struct {
  1822. Body []byte
  1823. HTTPResponse *http.Response
  1824. JSON200 *AppInfo
  1825. }
  1826. // Status returns HTTPResponse.Status
  1827. func (r PostAppInfoResponse) Status() string {
  1828. if r.HTTPResponse != nil {
  1829. return r.HTTPResponse.Status
  1830. }
  1831. return http.StatusText(0)
  1832. }
  1833. // StatusCode returns HTTPResponse.StatusCode
  1834. func (r PostAppInfoResponse) StatusCode() int {
  1835. if r.HTTPResponse != nil {
  1836. return r.HTTPResponse.StatusCode
  1837. }
  1838. return 0
  1839. }
  1840. type PostAppInitializeResponse struct {
  1841. Body []byte
  1842. HTTPResponse *http.Response
  1843. JSON200 *bool
  1844. }
  1845. // Status returns HTTPResponse.Status
  1846. func (r PostAppInitializeResponse) Status() string {
  1847. if r.HTTPResponse != nil {
  1848. return r.HTTPResponse.Status
  1849. }
  1850. return http.StatusText(0)
  1851. }
  1852. // StatusCode returns HTTPResponse.StatusCode
  1853. func (r PostAppInitializeResponse) StatusCode() int {
  1854. if r.HTTPResponse != nil {
  1855. return r.HTTPResponse.StatusCode
  1856. }
  1857. return 0
  1858. }
  1859. type GetEventResponse struct {
  1860. Body []byte
  1861. HTTPResponse *http.Response
  1862. JSON200 *Event
  1863. }
  1864. // Status returns HTTPResponse.Status
  1865. func (r GetEventResponse) Status() string {
  1866. if r.HTTPResponse != nil {
  1867. return r.HTTPResponse.Status
  1868. }
  1869. return http.StatusText(0)
  1870. }
  1871. // StatusCode returns HTTPResponse.StatusCode
  1872. func (r GetEventResponse) StatusCode() int {
  1873. if r.HTTPResponse != nil {
  1874. return r.HTTPResponse.StatusCode
  1875. }
  1876. return 0
  1877. }
  1878. type PostFileSearchResponse struct {
  1879. Body []byte
  1880. HTTPResponse *http.Response
  1881. JSON200 *[]string
  1882. }
  1883. // Status returns HTTPResponse.Status
  1884. func (r PostFileSearchResponse) Status() string {
  1885. if r.HTTPResponse != nil {
  1886. return r.HTTPResponse.Status
  1887. }
  1888. return http.StatusText(0)
  1889. }
  1890. // StatusCode returns HTTPResponse.StatusCode
  1891. func (r PostFileSearchResponse) StatusCode() int {
  1892. if r.HTTPResponse != nil {
  1893. return r.HTTPResponse.StatusCode
  1894. }
  1895. return 0
  1896. }
  1897. type PostPathGetResponse struct {
  1898. Body []byte
  1899. HTTPResponse *http.Response
  1900. JSON200 *struct {
  1901. Config string `json:"config"`
  1902. Cwd string `json:"cwd"`
  1903. Data string `json:"data"`
  1904. Root string `json:"root"`
  1905. }
  1906. }
  1907. // Status returns HTTPResponse.Status
  1908. func (r PostPathGetResponse) Status() string {
  1909. if r.HTTPResponse != nil {
  1910. return r.HTTPResponse.Status
  1911. }
  1912. return http.StatusText(0)
  1913. }
  1914. // StatusCode returns HTTPResponse.StatusCode
  1915. func (r PostPathGetResponse) StatusCode() int {
  1916. if r.HTTPResponse != nil {
  1917. return r.HTTPResponse.StatusCode
  1918. }
  1919. return 0
  1920. }
  1921. type PostProviderListResponse struct {
  1922. Body []byte
  1923. HTTPResponse *http.Response
  1924. JSON200 *struct {
  1925. Default map[string]string `json:"default"`
  1926. Providers []ProviderInfo `json:"providers"`
  1927. }
  1928. }
  1929. // Status returns HTTPResponse.Status
  1930. func (r PostProviderListResponse) Status() string {
  1931. if r.HTTPResponse != nil {
  1932. return r.HTTPResponse.Status
  1933. }
  1934. return http.StatusText(0)
  1935. }
  1936. // StatusCode returns HTTPResponse.StatusCode
  1937. func (r PostProviderListResponse) StatusCode() int {
  1938. if r.HTTPResponse != nil {
  1939. return r.HTTPResponse.StatusCode
  1940. }
  1941. return 0
  1942. }
  1943. type PostSessionAbortResponse struct {
  1944. Body []byte
  1945. HTTPResponse *http.Response
  1946. JSON200 *bool
  1947. }
  1948. // Status returns HTTPResponse.Status
  1949. func (r PostSessionAbortResponse) Status() string {
  1950. if r.HTTPResponse != nil {
  1951. return r.HTTPResponse.Status
  1952. }
  1953. return http.StatusText(0)
  1954. }
  1955. // StatusCode returns HTTPResponse.StatusCode
  1956. func (r PostSessionAbortResponse) StatusCode() int {
  1957. if r.HTTPResponse != nil {
  1958. return r.HTTPResponse.StatusCode
  1959. }
  1960. return 0
  1961. }
  1962. type PostSessionChatResponse struct {
  1963. Body []byte
  1964. HTTPResponse *http.Response
  1965. JSON200 *MessageInfo
  1966. }
  1967. // Status returns HTTPResponse.Status
  1968. func (r PostSessionChatResponse) Status() string {
  1969. if r.HTTPResponse != nil {
  1970. return r.HTTPResponse.Status
  1971. }
  1972. return http.StatusText(0)
  1973. }
  1974. // StatusCode returns HTTPResponse.StatusCode
  1975. func (r PostSessionChatResponse) StatusCode() int {
  1976. if r.HTTPResponse != nil {
  1977. return r.HTTPResponse.StatusCode
  1978. }
  1979. return 0
  1980. }
  1981. type PostSessionCreateResponse struct {
  1982. Body []byte
  1983. HTTPResponse *http.Response
  1984. JSON200 *SessionInfo
  1985. JSON400 *Error
  1986. }
  1987. // Status returns HTTPResponse.Status
  1988. func (r PostSessionCreateResponse) Status() string {
  1989. if r.HTTPResponse != nil {
  1990. return r.HTTPResponse.Status
  1991. }
  1992. return http.StatusText(0)
  1993. }
  1994. // StatusCode returns HTTPResponse.StatusCode
  1995. func (r PostSessionCreateResponse) StatusCode() int {
  1996. if r.HTTPResponse != nil {
  1997. return r.HTTPResponse.StatusCode
  1998. }
  1999. return 0
  2000. }
  2001. type PostSessionInitializeResponse struct {
  2002. Body []byte
  2003. HTTPResponse *http.Response
  2004. JSON200 *bool
  2005. }
  2006. // Status returns HTTPResponse.Status
  2007. func (r PostSessionInitializeResponse) Status() string {
  2008. if r.HTTPResponse != nil {
  2009. return r.HTTPResponse.Status
  2010. }
  2011. return http.StatusText(0)
  2012. }
  2013. // StatusCode returns HTTPResponse.StatusCode
  2014. func (r PostSessionInitializeResponse) StatusCode() int {
  2015. if r.HTTPResponse != nil {
  2016. return r.HTTPResponse.StatusCode
  2017. }
  2018. return 0
  2019. }
  2020. type PostSessionListResponse struct {
  2021. Body []byte
  2022. HTTPResponse *http.Response
  2023. JSON200 *[]SessionInfo
  2024. }
  2025. // Status returns HTTPResponse.Status
  2026. func (r PostSessionListResponse) Status() string {
  2027. if r.HTTPResponse != nil {
  2028. return r.HTTPResponse.Status
  2029. }
  2030. return http.StatusText(0)
  2031. }
  2032. // StatusCode returns HTTPResponse.StatusCode
  2033. func (r PostSessionListResponse) StatusCode() int {
  2034. if r.HTTPResponse != nil {
  2035. return r.HTTPResponse.StatusCode
  2036. }
  2037. return 0
  2038. }
  2039. type PostSessionMessagesResponse struct {
  2040. Body []byte
  2041. HTTPResponse *http.Response
  2042. JSON200 *[]MessageInfo
  2043. }
  2044. // Status returns HTTPResponse.Status
  2045. func (r PostSessionMessagesResponse) Status() string {
  2046. if r.HTTPResponse != nil {
  2047. return r.HTTPResponse.Status
  2048. }
  2049. return http.StatusText(0)
  2050. }
  2051. // StatusCode returns HTTPResponse.StatusCode
  2052. func (r PostSessionMessagesResponse) StatusCode() int {
  2053. if r.HTTPResponse != nil {
  2054. return r.HTTPResponse.StatusCode
  2055. }
  2056. return 0
  2057. }
  2058. type PostSessionShareResponse struct {
  2059. Body []byte
  2060. HTTPResponse *http.Response
  2061. JSON200 *SessionInfo
  2062. }
  2063. // Status returns HTTPResponse.Status
  2064. func (r PostSessionShareResponse) Status() string {
  2065. if r.HTTPResponse != nil {
  2066. return r.HTTPResponse.Status
  2067. }
  2068. return http.StatusText(0)
  2069. }
  2070. // StatusCode returns HTTPResponse.StatusCode
  2071. func (r PostSessionShareResponse) StatusCode() int {
  2072. if r.HTTPResponse != nil {
  2073. return r.HTTPResponse.StatusCode
  2074. }
  2075. return 0
  2076. }
  2077. type PostSessionSummarizeResponse struct {
  2078. Body []byte
  2079. HTTPResponse *http.Response
  2080. JSON200 *bool
  2081. }
  2082. // Status returns HTTPResponse.Status
  2083. func (r PostSessionSummarizeResponse) Status() string {
  2084. if r.HTTPResponse != nil {
  2085. return r.HTTPResponse.Status
  2086. }
  2087. return http.StatusText(0)
  2088. }
  2089. // StatusCode returns HTTPResponse.StatusCode
  2090. func (r PostSessionSummarizeResponse) StatusCode() int {
  2091. if r.HTTPResponse != nil {
  2092. return r.HTTPResponse.StatusCode
  2093. }
  2094. return 0
  2095. }
  2096. // PostAppInfoWithResponse request returning *PostAppInfoResponse
  2097. func (c *ClientWithResponses) PostAppInfoWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*PostAppInfoResponse, error) {
  2098. rsp, err := c.PostAppInfo(ctx, reqEditors...)
  2099. if err != nil {
  2100. return nil, err
  2101. }
  2102. return ParsePostAppInfoResponse(rsp)
  2103. }
  2104. // PostAppInitializeWithResponse request returning *PostAppInitializeResponse
  2105. func (c *ClientWithResponses) PostAppInitializeWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*PostAppInitializeResponse, error) {
  2106. rsp, err := c.PostAppInitialize(ctx, reqEditors...)
  2107. if err != nil {
  2108. return nil, err
  2109. }
  2110. return ParsePostAppInitializeResponse(rsp)
  2111. }
  2112. // GetEventWithResponse request returning *GetEventResponse
  2113. func (c *ClientWithResponses) GetEventWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*GetEventResponse, error) {
  2114. rsp, err := c.GetEvent(ctx, reqEditors...)
  2115. if err != nil {
  2116. return nil, err
  2117. }
  2118. return ParseGetEventResponse(rsp)
  2119. }
  2120. // PostFileSearchWithBodyWithResponse request with arbitrary body returning *PostFileSearchResponse
  2121. func (c *ClientWithResponses) PostFileSearchWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*PostFileSearchResponse, error) {
  2122. rsp, err := c.PostFileSearchWithBody(ctx, contentType, body, reqEditors...)
  2123. if err != nil {
  2124. return nil, err
  2125. }
  2126. return ParsePostFileSearchResponse(rsp)
  2127. }
  2128. func (c *ClientWithResponses) PostFileSearchWithResponse(ctx context.Context, body PostFileSearchJSONRequestBody, reqEditors ...RequestEditorFn) (*PostFileSearchResponse, error) {
  2129. rsp, err := c.PostFileSearch(ctx, body, reqEditors...)
  2130. if err != nil {
  2131. return nil, err
  2132. }
  2133. return ParsePostFileSearchResponse(rsp)
  2134. }
  2135. // PostPathGetWithResponse request returning *PostPathGetResponse
  2136. func (c *ClientWithResponses) PostPathGetWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*PostPathGetResponse, error) {
  2137. rsp, err := c.PostPathGet(ctx, reqEditors...)
  2138. if err != nil {
  2139. return nil, err
  2140. }
  2141. return ParsePostPathGetResponse(rsp)
  2142. }
  2143. // PostProviderListWithResponse request returning *PostProviderListResponse
  2144. func (c *ClientWithResponses) PostProviderListWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*PostProviderListResponse, error) {
  2145. rsp, err := c.PostProviderList(ctx, reqEditors...)
  2146. if err != nil {
  2147. return nil, err
  2148. }
  2149. return ParsePostProviderListResponse(rsp)
  2150. }
  2151. // PostSessionAbortWithBodyWithResponse request with arbitrary body returning *PostSessionAbortResponse
  2152. func (c *ClientWithResponses) PostSessionAbortWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*PostSessionAbortResponse, error) {
  2153. rsp, err := c.PostSessionAbortWithBody(ctx, contentType, body, reqEditors...)
  2154. if err != nil {
  2155. return nil, err
  2156. }
  2157. return ParsePostSessionAbortResponse(rsp)
  2158. }
  2159. func (c *ClientWithResponses) PostSessionAbortWithResponse(ctx context.Context, body PostSessionAbortJSONRequestBody, reqEditors ...RequestEditorFn) (*PostSessionAbortResponse, error) {
  2160. rsp, err := c.PostSessionAbort(ctx, body, reqEditors...)
  2161. if err != nil {
  2162. return nil, err
  2163. }
  2164. return ParsePostSessionAbortResponse(rsp)
  2165. }
  2166. // PostSessionChatWithBodyWithResponse request with arbitrary body returning *PostSessionChatResponse
  2167. func (c *ClientWithResponses) PostSessionChatWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*PostSessionChatResponse, error) {
  2168. rsp, err := c.PostSessionChatWithBody(ctx, contentType, body, reqEditors...)
  2169. if err != nil {
  2170. return nil, err
  2171. }
  2172. return ParsePostSessionChatResponse(rsp)
  2173. }
  2174. func (c *ClientWithResponses) PostSessionChatWithResponse(ctx context.Context, body PostSessionChatJSONRequestBody, reqEditors ...RequestEditorFn) (*PostSessionChatResponse, error) {
  2175. rsp, err := c.PostSessionChat(ctx, body, reqEditors...)
  2176. if err != nil {
  2177. return nil, err
  2178. }
  2179. return ParsePostSessionChatResponse(rsp)
  2180. }
  2181. // PostSessionCreateWithResponse request returning *PostSessionCreateResponse
  2182. func (c *ClientWithResponses) PostSessionCreateWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*PostSessionCreateResponse, error) {
  2183. rsp, err := c.PostSessionCreate(ctx, reqEditors...)
  2184. if err != nil {
  2185. return nil, err
  2186. }
  2187. return ParsePostSessionCreateResponse(rsp)
  2188. }
  2189. // PostSessionInitializeWithBodyWithResponse request with arbitrary body returning *PostSessionInitializeResponse
  2190. func (c *ClientWithResponses) PostSessionInitializeWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*PostSessionInitializeResponse, error) {
  2191. rsp, err := c.PostSessionInitializeWithBody(ctx, contentType, body, reqEditors...)
  2192. if err != nil {
  2193. return nil, err
  2194. }
  2195. return ParsePostSessionInitializeResponse(rsp)
  2196. }
  2197. func (c *ClientWithResponses) PostSessionInitializeWithResponse(ctx context.Context, body PostSessionInitializeJSONRequestBody, reqEditors ...RequestEditorFn) (*PostSessionInitializeResponse, error) {
  2198. rsp, err := c.PostSessionInitialize(ctx, body, reqEditors...)
  2199. if err != nil {
  2200. return nil, err
  2201. }
  2202. return ParsePostSessionInitializeResponse(rsp)
  2203. }
  2204. // PostSessionListWithResponse request returning *PostSessionListResponse
  2205. func (c *ClientWithResponses) PostSessionListWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*PostSessionListResponse, error) {
  2206. rsp, err := c.PostSessionList(ctx, reqEditors...)
  2207. if err != nil {
  2208. return nil, err
  2209. }
  2210. return ParsePostSessionListResponse(rsp)
  2211. }
  2212. // PostSessionMessagesWithBodyWithResponse request with arbitrary body returning *PostSessionMessagesResponse
  2213. func (c *ClientWithResponses) PostSessionMessagesWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*PostSessionMessagesResponse, error) {
  2214. rsp, err := c.PostSessionMessagesWithBody(ctx, contentType, body, reqEditors...)
  2215. if err != nil {
  2216. return nil, err
  2217. }
  2218. return ParsePostSessionMessagesResponse(rsp)
  2219. }
  2220. func (c *ClientWithResponses) PostSessionMessagesWithResponse(ctx context.Context, body PostSessionMessagesJSONRequestBody, reqEditors ...RequestEditorFn) (*PostSessionMessagesResponse, error) {
  2221. rsp, err := c.PostSessionMessages(ctx, body, reqEditors...)
  2222. if err != nil {
  2223. return nil, err
  2224. }
  2225. return ParsePostSessionMessagesResponse(rsp)
  2226. }
  2227. // PostSessionShareWithBodyWithResponse request with arbitrary body returning *PostSessionShareResponse
  2228. func (c *ClientWithResponses) PostSessionShareWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*PostSessionShareResponse, error) {
  2229. rsp, err := c.PostSessionShareWithBody(ctx, contentType, body, reqEditors...)
  2230. if err != nil {
  2231. return nil, err
  2232. }
  2233. return ParsePostSessionShareResponse(rsp)
  2234. }
  2235. func (c *ClientWithResponses) PostSessionShareWithResponse(ctx context.Context, body PostSessionShareJSONRequestBody, reqEditors ...RequestEditorFn) (*PostSessionShareResponse, error) {
  2236. rsp, err := c.PostSessionShare(ctx, body, reqEditors...)
  2237. if err != nil {
  2238. return nil, err
  2239. }
  2240. return ParsePostSessionShareResponse(rsp)
  2241. }
  2242. // PostSessionSummarizeWithBodyWithResponse request with arbitrary body returning *PostSessionSummarizeResponse
  2243. func (c *ClientWithResponses) PostSessionSummarizeWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*PostSessionSummarizeResponse, error) {
  2244. rsp, err := c.PostSessionSummarizeWithBody(ctx, contentType, body, reqEditors...)
  2245. if err != nil {
  2246. return nil, err
  2247. }
  2248. return ParsePostSessionSummarizeResponse(rsp)
  2249. }
  2250. func (c *ClientWithResponses) PostSessionSummarizeWithResponse(ctx context.Context, body PostSessionSummarizeJSONRequestBody, reqEditors ...RequestEditorFn) (*PostSessionSummarizeResponse, error) {
  2251. rsp, err := c.PostSessionSummarize(ctx, body, reqEditors...)
  2252. if err != nil {
  2253. return nil, err
  2254. }
  2255. return ParsePostSessionSummarizeResponse(rsp)
  2256. }
  2257. // ParsePostAppInfoResponse parses an HTTP response from a PostAppInfoWithResponse call
  2258. func ParsePostAppInfoResponse(rsp *http.Response) (*PostAppInfoResponse, error) {
  2259. bodyBytes, err := io.ReadAll(rsp.Body)
  2260. defer func() { _ = rsp.Body.Close() }()
  2261. if err != nil {
  2262. return nil, err
  2263. }
  2264. response := &PostAppInfoResponse{
  2265. Body: bodyBytes,
  2266. HTTPResponse: rsp,
  2267. }
  2268. switch {
  2269. case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200:
  2270. var dest AppInfo
  2271. if err := json.Unmarshal(bodyBytes, &dest); err != nil {
  2272. return nil, err
  2273. }
  2274. response.JSON200 = &dest
  2275. }
  2276. return response, nil
  2277. }
  2278. // ParsePostAppInitializeResponse parses an HTTP response from a PostAppInitializeWithResponse call
  2279. func ParsePostAppInitializeResponse(rsp *http.Response) (*PostAppInitializeResponse, error) {
  2280. bodyBytes, err := io.ReadAll(rsp.Body)
  2281. defer func() { _ = rsp.Body.Close() }()
  2282. if err != nil {
  2283. return nil, err
  2284. }
  2285. response := &PostAppInitializeResponse{
  2286. Body: bodyBytes,
  2287. HTTPResponse: rsp,
  2288. }
  2289. switch {
  2290. case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200:
  2291. var dest bool
  2292. if err := json.Unmarshal(bodyBytes, &dest); err != nil {
  2293. return nil, err
  2294. }
  2295. response.JSON200 = &dest
  2296. }
  2297. return response, nil
  2298. }
  2299. // ParseGetEventResponse parses an HTTP response from a GetEventWithResponse call
  2300. func ParseGetEventResponse(rsp *http.Response) (*GetEventResponse, error) {
  2301. bodyBytes, err := io.ReadAll(rsp.Body)
  2302. defer func() { _ = rsp.Body.Close() }()
  2303. if err != nil {
  2304. return nil, err
  2305. }
  2306. response := &GetEventResponse{
  2307. Body: bodyBytes,
  2308. HTTPResponse: rsp,
  2309. }
  2310. switch {
  2311. case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200:
  2312. var dest Event
  2313. if err := json.Unmarshal(bodyBytes, &dest); err != nil {
  2314. return nil, err
  2315. }
  2316. response.JSON200 = &dest
  2317. }
  2318. return response, nil
  2319. }
  2320. // ParsePostFileSearchResponse parses an HTTP response from a PostFileSearchWithResponse call
  2321. func ParsePostFileSearchResponse(rsp *http.Response) (*PostFileSearchResponse, error) {
  2322. bodyBytes, err := io.ReadAll(rsp.Body)
  2323. defer func() { _ = rsp.Body.Close() }()
  2324. if err != nil {
  2325. return nil, err
  2326. }
  2327. response := &PostFileSearchResponse{
  2328. Body: bodyBytes,
  2329. HTTPResponse: rsp,
  2330. }
  2331. switch {
  2332. case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200:
  2333. var dest []string
  2334. if err := json.Unmarshal(bodyBytes, &dest); err != nil {
  2335. return nil, err
  2336. }
  2337. response.JSON200 = &dest
  2338. }
  2339. return response, nil
  2340. }
  2341. // ParsePostPathGetResponse parses an HTTP response from a PostPathGetWithResponse call
  2342. func ParsePostPathGetResponse(rsp *http.Response) (*PostPathGetResponse, error) {
  2343. bodyBytes, err := io.ReadAll(rsp.Body)
  2344. defer func() { _ = rsp.Body.Close() }()
  2345. if err != nil {
  2346. return nil, err
  2347. }
  2348. response := &PostPathGetResponse{
  2349. Body: bodyBytes,
  2350. HTTPResponse: rsp,
  2351. }
  2352. switch {
  2353. case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200:
  2354. var dest struct {
  2355. Config string `json:"config"`
  2356. Cwd string `json:"cwd"`
  2357. Data string `json:"data"`
  2358. Root string `json:"root"`
  2359. }
  2360. if err := json.Unmarshal(bodyBytes, &dest); err != nil {
  2361. return nil, err
  2362. }
  2363. response.JSON200 = &dest
  2364. }
  2365. return response, nil
  2366. }
  2367. // ParsePostProviderListResponse parses an HTTP response from a PostProviderListWithResponse call
  2368. func ParsePostProviderListResponse(rsp *http.Response) (*PostProviderListResponse, error) {
  2369. bodyBytes, err := io.ReadAll(rsp.Body)
  2370. defer func() { _ = rsp.Body.Close() }()
  2371. if err != nil {
  2372. return nil, err
  2373. }
  2374. response := &PostProviderListResponse{
  2375. Body: bodyBytes,
  2376. HTTPResponse: rsp,
  2377. }
  2378. switch {
  2379. case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200:
  2380. var dest struct {
  2381. Default map[string]string `json:"default"`
  2382. Providers []ProviderInfo `json:"providers"`
  2383. }
  2384. if err := json.Unmarshal(bodyBytes, &dest); err != nil {
  2385. return nil, err
  2386. }
  2387. response.JSON200 = &dest
  2388. }
  2389. return response, nil
  2390. }
  2391. // ParsePostSessionAbortResponse parses an HTTP response from a PostSessionAbortWithResponse call
  2392. func ParsePostSessionAbortResponse(rsp *http.Response) (*PostSessionAbortResponse, error) {
  2393. bodyBytes, err := io.ReadAll(rsp.Body)
  2394. defer func() { _ = rsp.Body.Close() }()
  2395. if err != nil {
  2396. return nil, err
  2397. }
  2398. response := &PostSessionAbortResponse{
  2399. Body: bodyBytes,
  2400. HTTPResponse: rsp,
  2401. }
  2402. switch {
  2403. case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200:
  2404. var dest bool
  2405. if err := json.Unmarshal(bodyBytes, &dest); err != nil {
  2406. return nil, err
  2407. }
  2408. response.JSON200 = &dest
  2409. }
  2410. return response, nil
  2411. }
  2412. // ParsePostSessionChatResponse parses an HTTP response from a PostSessionChatWithResponse call
  2413. func ParsePostSessionChatResponse(rsp *http.Response) (*PostSessionChatResponse, error) {
  2414. bodyBytes, err := io.ReadAll(rsp.Body)
  2415. defer func() { _ = rsp.Body.Close() }()
  2416. if err != nil {
  2417. return nil, err
  2418. }
  2419. response := &PostSessionChatResponse{
  2420. Body: bodyBytes,
  2421. HTTPResponse: rsp,
  2422. }
  2423. switch {
  2424. case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200:
  2425. var dest MessageInfo
  2426. if err := json.Unmarshal(bodyBytes, &dest); err != nil {
  2427. return nil, err
  2428. }
  2429. response.JSON200 = &dest
  2430. }
  2431. return response, nil
  2432. }
  2433. // ParsePostSessionCreateResponse parses an HTTP response from a PostSessionCreateWithResponse call
  2434. func ParsePostSessionCreateResponse(rsp *http.Response) (*PostSessionCreateResponse, error) {
  2435. bodyBytes, err := io.ReadAll(rsp.Body)
  2436. defer func() { _ = rsp.Body.Close() }()
  2437. if err != nil {
  2438. return nil, err
  2439. }
  2440. response := &PostSessionCreateResponse{
  2441. Body: bodyBytes,
  2442. HTTPResponse: rsp,
  2443. }
  2444. switch {
  2445. case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200:
  2446. var dest SessionInfo
  2447. if err := json.Unmarshal(bodyBytes, &dest); err != nil {
  2448. return nil, err
  2449. }
  2450. response.JSON200 = &dest
  2451. case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 400:
  2452. var dest Error
  2453. if err := json.Unmarshal(bodyBytes, &dest); err != nil {
  2454. return nil, err
  2455. }
  2456. response.JSON400 = &dest
  2457. }
  2458. return response, nil
  2459. }
  2460. // ParsePostSessionInitializeResponse parses an HTTP response from a PostSessionInitializeWithResponse call
  2461. func ParsePostSessionInitializeResponse(rsp *http.Response) (*PostSessionInitializeResponse, error) {
  2462. bodyBytes, err := io.ReadAll(rsp.Body)
  2463. defer func() { _ = rsp.Body.Close() }()
  2464. if err != nil {
  2465. return nil, err
  2466. }
  2467. response := &PostSessionInitializeResponse{
  2468. Body: bodyBytes,
  2469. HTTPResponse: rsp,
  2470. }
  2471. switch {
  2472. case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200:
  2473. var dest bool
  2474. if err := json.Unmarshal(bodyBytes, &dest); err != nil {
  2475. return nil, err
  2476. }
  2477. response.JSON200 = &dest
  2478. }
  2479. return response, nil
  2480. }
  2481. // ParsePostSessionListResponse parses an HTTP response from a PostSessionListWithResponse call
  2482. func ParsePostSessionListResponse(rsp *http.Response) (*PostSessionListResponse, error) {
  2483. bodyBytes, err := io.ReadAll(rsp.Body)
  2484. defer func() { _ = rsp.Body.Close() }()
  2485. if err != nil {
  2486. return nil, err
  2487. }
  2488. response := &PostSessionListResponse{
  2489. Body: bodyBytes,
  2490. HTTPResponse: rsp,
  2491. }
  2492. switch {
  2493. case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200:
  2494. var dest []SessionInfo
  2495. if err := json.Unmarshal(bodyBytes, &dest); err != nil {
  2496. return nil, err
  2497. }
  2498. response.JSON200 = &dest
  2499. }
  2500. return response, nil
  2501. }
  2502. // ParsePostSessionMessagesResponse parses an HTTP response from a PostSessionMessagesWithResponse call
  2503. func ParsePostSessionMessagesResponse(rsp *http.Response) (*PostSessionMessagesResponse, error) {
  2504. bodyBytes, err := io.ReadAll(rsp.Body)
  2505. defer func() { _ = rsp.Body.Close() }()
  2506. if err != nil {
  2507. return nil, err
  2508. }
  2509. response := &PostSessionMessagesResponse{
  2510. Body: bodyBytes,
  2511. HTTPResponse: rsp,
  2512. }
  2513. switch {
  2514. case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200:
  2515. var dest []MessageInfo
  2516. if err := json.Unmarshal(bodyBytes, &dest); err != nil {
  2517. return nil, err
  2518. }
  2519. response.JSON200 = &dest
  2520. }
  2521. return response, nil
  2522. }
  2523. // ParsePostSessionShareResponse parses an HTTP response from a PostSessionShareWithResponse call
  2524. func ParsePostSessionShareResponse(rsp *http.Response) (*PostSessionShareResponse, error) {
  2525. bodyBytes, err := io.ReadAll(rsp.Body)
  2526. defer func() { _ = rsp.Body.Close() }()
  2527. if err != nil {
  2528. return nil, err
  2529. }
  2530. response := &PostSessionShareResponse{
  2531. Body: bodyBytes,
  2532. HTTPResponse: rsp,
  2533. }
  2534. switch {
  2535. case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200:
  2536. var dest SessionInfo
  2537. if err := json.Unmarshal(bodyBytes, &dest); err != nil {
  2538. return nil, err
  2539. }
  2540. response.JSON200 = &dest
  2541. }
  2542. return response, nil
  2543. }
  2544. // ParsePostSessionSummarizeResponse parses an HTTP response from a PostSessionSummarizeWithResponse call
  2545. func ParsePostSessionSummarizeResponse(rsp *http.Response) (*PostSessionSummarizeResponse, error) {
  2546. bodyBytes, err := io.ReadAll(rsp.Body)
  2547. defer func() { _ = rsp.Body.Close() }()
  2548. if err != nil {
  2549. return nil, err
  2550. }
  2551. response := &PostSessionSummarizeResponse{
  2552. Body: bodyBytes,
  2553. HTTPResponse: rsp,
  2554. }
  2555. switch {
  2556. case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200:
  2557. var dest bool
  2558. if err := json.Unmarshal(bodyBytes, &dest); err != nil {
  2559. return nil, err
  2560. }
  2561. response.JSON200 = &dest
  2562. }
  2563. return response, nil
  2564. }