generated-client.go 83 KB

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