generated-client.go 59 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943
  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. // Event defines model for Event.
  24. type Event struct {
  25. union json.RawMessage
  26. }
  27. // EventLspClientDiagnostics defines model for Event.lsp.client.diagnostics.
  28. type EventLspClientDiagnostics struct {
  29. Properties struct {
  30. Path string `json:"path"`
  31. ServerID string `json:"serverID"`
  32. } `json:"properties"`
  33. Type string `json:"type"`
  34. }
  35. // EventMessageUpdated defines model for Event.message.updated.
  36. type EventMessageUpdated struct {
  37. Properties struct {
  38. Info MessageInfo `json:"info"`
  39. } `json:"properties"`
  40. Type string `json:"type"`
  41. }
  42. // EventSessionUpdated defines model for Event.session.updated.
  43. type EventSessionUpdated struct {
  44. Properties struct {
  45. Info SessionInfo `json:"info"`
  46. } `json:"properties"`
  47. Type string `json:"type"`
  48. }
  49. // EventStorageWrite defines model for Event.storage.write.
  50. type EventStorageWrite struct {
  51. Properties struct {
  52. Content *interface{} `json:"content,omitempty"`
  53. Key string `json:"key"`
  54. } `json:"properties"`
  55. Type string `json:"type"`
  56. }
  57. // MessageInfo defines model for Message.Info.
  58. type MessageInfo struct {
  59. Id string `json:"id"`
  60. Metadata struct {
  61. Assistant *struct {
  62. Cost float32 `json:"cost"`
  63. ModelID string `json:"modelID"`
  64. ProviderID string `json:"providerID"`
  65. Summary *bool `json:"summary,omitempty"`
  66. Tokens struct {
  67. Input float32 `json:"input"`
  68. Output float32 `json:"output"`
  69. Reasoning float32 `json:"reasoning"`
  70. } `json:"tokens"`
  71. } `json:"assistant,omitempty"`
  72. SessionID string `json:"sessionID"`
  73. Time struct {
  74. Completed *float32 `json:"completed,omitempty"`
  75. Created float32 `json:"created"`
  76. } `json:"time"`
  77. Tool map[string]interface{} `json:"tool"`
  78. } `json:"metadata"`
  79. Parts []MessagePart `json:"parts"`
  80. Role MessageInfoRole `json:"role"`
  81. }
  82. // MessageInfoRole defines model for MessageInfo.Role.
  83. type MessageInfoRole string
  84. // MessagePart defines model for Message.Part.
  85. type MessagePart struct {
  86. union json.RawMessage
  87. }
  88. // MessagePartFile defines model for Message.Part.File.
  89. type MessagePartFile struct {
  90. Filename *string `json:"filename,omitempty"`
  91. MediaType string `json:"mediaType"`
  92. Type string `json:"type"`
  93. Url string `json:"url"`
  94. }
  95. // MessagePartReasoning defines model for Message.Part.Reasoning.
  96. type MessagePartReasoning struct {
  97. ProviderMetadata *map[string]interface{} `json:"providerMetadata,omitempty"`
  98. Text string `json:"text"`
  99. Type string `json:"type"`
  100. }
  101. // MessagePartSourceUrl defines model for Message.Part.SourceUrl.
  102. type MessagePartSourceUrl struct {
  103. ProviderMetadata *map[string]interface{} `json:"providerMetadata,omitempty"`
  104. SourceId string `json:"sourceId"`
  105. Title *string `json:"title,omitempty"`
  106. Type string `json:"type"`
  107. Url string `json:"url"`
  108. }
  109. // MessagePartStepStart defines model for Message.Part.StepStart.
  110. type MessagePartStepStart struct {
  111. Type string `json:"type"`
  112. }
  113. // MessagePartText defines model for Message.Part.Text.
  114. type MessagePartText struct {
  115. Text string `json:"text"`
  116. Type string `json:"type"`
  117. }
  118. // MessagePartToolInvocation defines model for Message.Part.ToolInvocation.
  119. type MessagePartToolInvocation struct {
  120. ToolInvocation MessageToolInvocation `json:"toolInvocation"`
  121. Type string `json:"type"`
  122. }
  123. // MessageToolInvocation defines model for Message.ToolInvocation.
  124. type MessageToolInvocation struct {
  125. union json.RawMessage
  126. }
  127. // MessageToolInvocationToolCall defines model for Message.ToolInvocation.ToolCall.
  128. type MessageToolInvocationToolCall struct {
  129. Args *interface{} `json:"args,omitempty"`
  130. State string `json:"state"`
  131. Step *float32 `json:"step,omitempty"`
  132. ToolCallId string `json:"toolCallId"`
  133. ToolName string `json:"toolName"`
  134. }
  135. // MessageToolInvocationToolPartialCall defines model for Message.ToolInvocation.ToolPartialCall.
  136. type MessageToolInvocationToolPartialCall struct {
  137. Args *interface{} `json:"args,omitempty"`
  138. State string `json:"state"`
  139. Step *float32 `json:"step,omitempty"`
  140. ToolCallId string `json:"toolCallId"`
  141. ToolName string `json:"toolName"`
  142. }
  143. // MessageToolInvocationToolResult defines model for Message.ToolInvocation.ToolResult.
  144. type MessageToolInvocationToolResult struct {
  145. Args *interface{} `json:"args,omitempty"`
  146. Result string `json:"result"`
  147. State string `json:"state"`
  148. Step *float32 `json:"step,omitempty"`
  149. ToolCallId string `json:"toolCallId"`
  150. ToolName string `json:"toolName"`
  151. }
  152. // ProviderInfo defines model for Provider.Info.
  153. type ProviderInfo struct {
  154. Models map[string]ProviderModel `json:"models"`
  155. Options *map[string]interface{} `json:"options,omitempty"`
  156. }
  157. // ProviderModel defines model for Provider.Model.
  158. type ProviderModel struct {
  159. Attachment bool `json:"attachment"`
  160. ContextWindow float32 `json:"contextWindow"`
  161. Cost struct {
  162. Input float32 `json:"input"`
  163. InputCached float32 `json:"inputCached"`
  164. Output float32 `json:"output"`
  165. OutputCached float32 `json:"outputCached"`
  166. } `json:"cost"`
  167. MaxOutputTokens *float32 `json:"maxOutputTokens,omitempty"`
  168. Name *string `json:"name,omitempty"`
  169. Reasoning *bool `json:"reasoning,omitempty"`
  170. }
  171. // SessionInfo defines model for session.info.
  172. type SessionInfo struct {
  173. Id string `json:"id"`
  174. ShareID *string `json:"shareID,omitempty"`
  175. Title string `json:"title"`
  176. }
  177. // PostSessionAbortJSONBody defines parameters for PostSessionAbort.
  178. type PostSessionAbortJSONBody struct {
  179. SessionID string `json:"sessionID"`
  180. }
  181. // PostSessionChatJSONBody defines parameters for PostSessionChat.
  182. type PostSessionChatJSONBody struct {
  183. ModelID string `json:"modelID"`
  184. Parts []MessagePart `json:"parts"`
  185. ProviderID string `json:"providerID"`
  186. SessionID string `json:"sessionID"`
  187. }
  188. // PostSessionMessagesJSONBody defines parameters for PostSessionMessages.
  189. type PostSessionMessagesJSONBody struct {
  190. SessionID string `json:"sessionID"`
  191. }
  192. // PostSessionShareJSONBody defines parameters for PostSessionShare.
  193. type PostSessionShareJSONBody struct {
  194. SessionID string `json:"sessionID"`
  195. }
  196. // PostSessionSummarizeJSONBody defines parameters for PostSessionSummarize.
  197. type PostSessionSummarizeJSONBody struct {
  198. ModelID string `json:"modelID"`
  199. ProviderID string `json:"providerID"`
  200. SessionID string `json:"sessionID"`
  201. }
  202. // PostSessionAbortJSONRequestBody defines body for PostSessionAbort for application/json ContentType.
  203. type PostSessionAbortJSONRequestBody PostSessionAbortJSONBody
  204. // PostSessionChatJSONRequestBody defines body for PostSessionChat for application/json ContentType.
  205. type PostSessionChatJSONRequestBody PostSessionChatJSONBody
  206. // PostSessionMessagesJSONRequestBody defines body for PostSessionMessages for application/json ContentType.
  207. type PostSessionMessagesJSONRequestBody PostSessionMessagesJSONBody
  208. // PostSessionShareJSONRequestBody defines body for PostSessionShare for application/json ContentType.
  209. type PostSessionShareJSONRequestBody PostSessionShareJSONBody
  210. // PostSessionSummarizeJSONRequestBody defines body for PostSessionSummarize for application/json ContentType.
  211. type PostSessionSummarizeJSONRequestBody PostSessionSummarizeJSONBody
  212. // AsEventStorageWrite returns the union data inside the Event as a EventStorageWrite
  213. func (t Event) AsEventStorageWrite() (EventStorageWrite, error) {
  214. var body EventStorageWrite
  215. err := json.Unmarshal(t.union, &body)
  216. return body, err
  217. }
  218. // FromEventStorageWrite overwrites any union data inside the Event as the provided EventStorageWrite
  219. func (t *Event) FromEventStorageWrite(v EventStorageWrite) error {
  220. v.Type = "storage.write"
  221. b, err := json.Marshal(v)
  222. t.union = b
  223. return err
  224. }
  225. // MergeEventStorageWrite performs a merge with any union data inside the Event, using the provided EventStorageWrite
  226. func (t *Event) MergeEventStorageWrite(v EventStorageWrite) error {
  227. v.Type = "storage.write"
  228. b, err := json.Marshal(v)
  229. if err != nil {
  230. return err
  231. }
  232. merged, err := runtime.JSONMerge(t.union, b)
  233. t.union = merged
  234. return err
  235. }
  236. // AsEventLspClientDiagnostics returns the union data inside the Event as a EventLspClientDiagnostics
  237. func (t Event) AsEventLspClientDiagnostics() (EventLspClientDiagnostics, error) {
  238. var body EventLspClientDiagnostics
  239. err := json.Unmarshal(t.union, &body)
  240. return body, err
  241. }
  242. // FromEventLspClientDiagnostics overwrites any union data inside the Event as the provided EventLspClientDiagnostics
  243. func (t *Event) FromEventLspClientDiagnostics(v EventLspClientDiagnostics) error {
  244. v.Type = "lsp.client.diagnostics"
  245. b, err := json.Marshal(v)
  246. t.union = b
  247. return err
  248. }
  249. // MergeEventLspClientDiagnostics performs a merge with any union data inside the Event, using the provided EventLspClientDiagnostics
  250. func (t *Event) MergeEventLspClientDiagnostics(v EventLspClientDiagnostics) error {
  251. v.Type = "lsp.client.diagnostics"
  252. b, err := json.Marshal(v)
  253. if err != nil {
  254. return err
  255. }
  256. merged, err := runtime.JSONMerge(t.union, b)
  257. t.union = merged
  258. return err
  259. }
  260. // AsEventMessageUpdated returns the union data inside the Event as a EventMessageUpdated
  261. func (t Event) AsEventMessageUpdated() (EventMessageUpdated, error) {
  262. var body EventMessageUpdated
  263. err := json.Unmarshal(t.union, &body)
  264. return body, err
  265. }
  266. // FromEventMessageUpdated overwrites any union data inside the Event as the provided EventMessageUpdated
  267. func (t *Event) FromEventMessageUpdated(v EventMessageUpdated) error {
  268. v.Type = "message.updated"
  269. b, err := json.Marshal(v)
  270. t.union = b
  271. return err
  272. }
  273. // MergeEventMessageUpdated performs a merge with any union data inside the Event, using the provided EventMessageUpdated
  274. func (t *Event) MergeEventMessageUpdated(v EventMessageUpdated) error {
  275. v.Type = "message.updated"
  276. b, err := json.Marshal(v)
  277. if err != nil {
  278. return err
  279. }
  280. merged, err := runtime.JSONMerge(t.union, b)
  281. t.union = merged
  282. return err
  283. }
  284. // AsEventSessionUpdated returns the union data inside the Event as a EventSessionUpdated
  285. func (t Event) AsEventSessionUpdated() (EventSessionUpdated, error) {
  286. var body EventSessionUpdated
  287. err := json.Unmarshal(t.union, &body)
  288. return body, err
  289. }
  290. // FromEventSessionUpdated overwrites any union data inside the Event as the provided EventSessionUpdated
  291. func (t *Event) FromEventSessionUpdated(v EventSessionUpdated) error {
  292. v.Type = "session.updated"
  293. b, err := json.Marshal(v)
  294. t.union = b
  295. return err
  296. }
  297. // MergeEventSessionUpdated performs a merge with any union data inside the Event, using the provided EventSessionUpdated
  298. func (t *Event) MergeEventSessionUpdated(v EventSessionUpdated) error {
  299. v.Type = "session.updated"
  300. b, err := json.Marshal(v)
  301. if err != nil {
  302. return err
  303. }
  304. merged, err := runtime.JSONMerge(t.union, b)
  305. t.union = merged
  306. return err
  307. }
  308. func (t Event) Discriminator() (string, error) {
  309. var discriminator struct {
  310. Discriminator string `json:"type"`
  311. }
  312. err := json.Unmarshal(t.union, &discriminator)
  313. return discriminator.Discriminator, err
  314. }
  315. func (t Event) ValueByDiscriminator() (interface{}, error) {
  316. discriminator, err := t.Discriminator()
  317. if err != nil {
  318. return nil, err
  319. }
  320. switch discriminator {
  321. case "lsp.client.diagnostics":
  322. return t.AsEventLspClientDiagnostics()
  323. case "message.updated":
  324. return t.AsEventMessageUpdated()
  325. case "session.updated":
  326. return t.AsEventSessionUpdated()
  327. case "storage.write":
  328. return t.AsEventStorageWrite()
  329. default:
  330. return nil, errors.New("unknown discriminator value: " + discriminator)
  331. }
  332. }
  333. func (t Event) MarshalJSON() ([]byte, error) {
  334. b, err := t.union.MarshalJSON()
  335. return b, err
  336. }
  337. func (t *Event) UnmarshalJSON(b []byte) error {
  338. err := t.union.UnmarshalJSON(b)
  339. return err
  340. }
  341. // AsMessagePartText returns the union data inside the MessagePart as a MessagePartText
  342. func (t MessagePart) AsMessagePartText() (MessagePartText, error) {
  343. var body MessagePartText
  344. err := json.Unmarshal(t.union, &body)
  345. return body, err
  346. }
  347. // FromMessagePartText overwrites any union data inside the MessagePart as the provided MessagePartText
  348. func (t *MessagePart) FromMessagePartText(v MessagePartText) error {
  349. v.Type = "text"
  350. b, err := json.Marshal(v)
  351. t.union = b
  352. return err
  353. }
  354. // MergeMessagePartText performs a merge with any union data inside the MessagePart, using the provided MessagePartText
  355. func (t *MessagePart) MergeMessagePartText(v MessagePartText) error {
  356. v.Type = "text"
  357. b, err := json.Marshal(v)
  358. if err != nil {
  359. return err
  360. }
  361. merged, err := runtime.JSONMerge(t.union, b)
  362. t.union = merged
  363. return err
  364. }
  365. // AsMessagePartReasoning returns the union data inside the MessagePart as a MessagePartReasoning
  366. func (t MessagePart) AsMessagePartReasoning() (MessagePartReasoning, error) {
  367. var body MessagePartReasoning
  368. err := json.Unmarshal(t.union, &body)
  369. return body, err
  370. }
  371. // FromMessagePartReasoning overwrites any union data inside the MessagePart as the provided MessagePartReasoning
  372. func (t *MessagePart) FromMessagePartReasoning(v MessagePartReasoning) error {
  373. v.Type = "reasoning"
  374. b, err := json.Marshal(v)
  375. t.union = b
  376. return err
  377. }
  378. // MergeMessagePartReasoning performs a merge with any union data inside the MessagePart, using the provided MessagePartReasoning
  379. func (t *MessagePart) MergeMessagePartReasoning(v MessagePartReasoning) error {
  380. v.Type = "reasoning"
  381. b, err := json.Marshal(v)
  382. if err != nil {
  383. return err
  384. }
  385. merged, err := runtime.JSONMerge(t.union, b)
  386. t.union = merged
  387. return err
  388. }
  389. // AsMessagePartToolInvocation returns the union data inside the MessagePart as a MessagePartToolInvocation
  390. func (t MessagePart) AsMessagePartToolInvocation() (MessagePartToolInvocation, error) {
  391. var body MessagePartToolInvocation
  392. err := json.Unmarshal(t.union, &body)
  393. return body, err
  394. }
  395. // FromMessagePartToolInvocation overwrites any union data inside the MessagePart as the provided MessagePartToolInvocation
  396. func (t *MessagePart) FromMessagePartToolInvocation(v MessagePartToolInvocation) error {
  397. v.Type = "tool-invocation"
  398. b, err := json.Marshal(v)
  399. t.union = b
  400. return err
  401. }
  402. // MergeMessagePartToolInvocation performs a merge with any union data inside the MessagePart, using the provided MessagePartToolInvocation
  403. func (t *MessagePart) MergeMessagePartToolInvocation(v MessagePartToolInvocation) error {
  404. v.Type = "tool-invocation"
  405. b, err := json.Marshal(v)
  406. if err != nil {
  407. return err
  408. }
  409. merged, err := runtime.JSONMerge(t.union, b)
  410. t.union = merged
  411. return err
  412. }
  413. // AsMessagePartSourceUrl returns the union data inside the MessagePart as a MessagePartSourceUrl
  414. func (t MessagePart) AsMessagePartSourceUrl() (MessagePartSourceUrl, error) {
  415. var body MessagePartSourceUrl
  416. err := json.Unmarshal(t.union, &body)
  417. return body, err
  418. }
  419. // FromMessagePartSourceUrl overwrites any union data inside the MessagePart as the provided MessagePartSourceUrl
  420. func (t *MessagePart) FromMessagePartSourceUrl(v MessagePartSourceUrl) error {
  421. v.Type = "source-url"
  422. b, err := json.Marshal(v)
  423. t.union = b
  424. return err
  425. }
  426. // MergeMessagePartSourceUrl performs a merge with any union data inside the MessagePart, using the provided MessagePartSourceUrl
  427. func (t *MessagePart) MergeMessagePartSourceUrl(v MessagePartSourceUrl) error {
  428. v.Type = "source-url"
  429. b, err := json.Marshal(v)
  430. if err != nil {
  431. return err
  432. }
  433. merged, err := runtime.JSONMerge(t.union, b)
  434. t.union = merged
  435. return err
  436. }
  437. // AsMessagePartFile returns the union data inside the MessagePart as a MessagePartFile
  438. func (t MessagePart) AsMessagePartFile() (MessagePartFile, error) {
  439. var body MessagePartFile
  440. err := json.Unmarshal(t.union, &body)
  441. return body, err
  442. }
  443. // FromMessagePartFile overwrites any union data inside the MessagePart as the provided MessagePartFile
  444. func (t *MessagePart) FromMessagePartFile(v MessagePartFile) error {
  445. v.Type = "file"
  446. b, err := json.Marshal(v)
  447. t.union = b
  448. return err
  449. }
  450. // MergeMessagePartFile performs a merge with any union data inside the MessagePart, using the provided MessagePartFile
  451. func (t *MessagePart) MergeMessagePartFile(v MessagePartFile) error {
  452. v.Type = "file"
  453. b, err := json.Marshal(v)
  454. if err != nil {
  455. return err
  456. }
  457. merged, err := runtime.JSONMerge(t.union, b)
  458. t.union = merged
  459. return err
  460. }
  461. // AsMessagePartStepStart returns the union data inside the MessagePart as a MessagePartStepStart
  462. func (t MessagePart) AsMessagePartStepStart() (MessagePartStepStart, error) {
  463. var body MessagePartStepStart
  464. err := json.Unmarshal(t.union, &body)
  465. return body, err
  466. }
  467. // FromMessagePartStepStart overwrites any union data inside the MessagePart as the provided MessagePartStepStart
  468. func (t *MessagePart) FromMessagePartStepStart(v MessagePartStepStart) error {
  469. v.Type = "step-start"
  470. b, err := json.Marshal(v)
  471. t.union = b
  472. return err
  473. }
  474. // MergeMessagePartStepStart performs a merge with any union data inside the MessagePart, using the provided MessagePartStepStart
  475. func (t *MessagePart) MergeMessagePartStepStart(v MessagePartStepStart) error {
  476. v.Type = "step-start"
  477. b, err := json.Marshal(v)
  478. if err != nil {
  479. return err
  480. }
  481. merged, err := runtime.JSONMerge(t.union, b)
  482. t.union = merged
  483. return err
  484. }
  485. func (t MessagePart) Discriminator() (string, error) {
  486. var discriminator struct {
  487. Discriminator string `json:"type"`
  488. }
  489. err := json.Unmarshal(t.union, &discriminator)
  490. return discriminator.Discriminator, err
  491. }
  492. func (t MessagePart) ValueByDiscriminator() (interface{}, error) {
  493. discriminator, err := t.Discriminator()
  494. if err != nil {
  495. return nil, err
  496. }
  497. switch discriminator {
  498. case "file":
  499. return t.AsMessagePartFile()
  500. case "reasoning":
  501. return t.AsMessagePartReasoning()
  502. case "source-url":
  503. return t.AsMessagePartSourceUrl()
  504. case "step-start":
  505. return t.AsMessagePartStepStart()
  506. case "text":
  507. return t.AsMessagePartText()
  508. case "tool-invocation":
  509. return t.AsMessagePartToolInvocation()
  510. default:
  511. return nil, errors.New("unknown discriminator value: " + discriminator)
  512. }
  513. }
  514. func (t MessagePart) MarshalJSON() ([]byte, error) {
  515. b, err := t.union.MarshalJSON()
  516. return b, err
  517. }
  518. func (t *MessagePart) UnmarshalJSON(b []byte) error {
  519. err := t.union.UnmarshalJSON(b)
  520. return err
  521. }
  522. // AsMessageToolInvocationToolCall returns the union data inside the MessageToolInvocation as a MessageToolInvocationToolCall
  523. func (t MessageToolInvocation) AsMessageToolInvocationToolCall() (MessageToolInvocationToolCall, error) {
  524. var body MessageToolInvocationToolCall
  525. err := json.Unmarshal(t.union, &body)
  526. return body, err
  527. }
  528. // FromMessageToolInvocationToolCall overwrites any union data inside the MessageToolInvocation as the provided MessageToolInvocationToolCall
  529. func (t *MessageToolInvocation) FromMessageToolInvocationToolCall(v MessageToolInvocationToolCall) error {
  530. v.State = "call"
  531. b, err := json.Marshal(v)
  532. t.union = b
  533. return err
  534. }
  535. // MergeMessageToolInvocationToolCall performs a merge with any union data inside the MessageToolInvocation, using the provided MessageToolInvocationToolCall
  536. func (t *MessageToolInvocation) MergeMessageToolInvocationToolCall(v MessageToolInvocationToolCall) error {
  537. v.State = "call"
  538. b, err := json.Marshal(v)
  539. if err != nil {
  540. return err
  541. }
  542. merged, err := runtime.JSONMerge(t.union, b)
  543. t.union = merged
  544. return err
  545. }
  546. // AsMessageToolInvocationToolPartialCall returns the union data inside the MessageToolInvocation as a MessageToolInvocationToolPartialCall
  547. func (t MessageToolInvocation) AsMessageToolInvocationToolPartialCall() (MessageToolInvocationToolPartialCall, error) {
  548. var body MessageToolInvocationToolPartialCall
  549. err := json.Unmarshal(t.union, &body)
  550. return body, err
  551. }
  552. // FromMessageToolInvocationToolPartialCall overwrites any union data inside the MessageToolInvocation as the provided MessageToolInvocationToolPartialCall
  553. func (t *MessageToolInvocation) FromMessageToolInvocationToolPartialCall(v MessageToolInvocationToolPartialCall) error {
  554. v.State = "partial-call"
  555. b, err := json.Marshal(v)
  556. t.union = b
  557. return err
  558. }
  559. // MergeMessageToolInvocationToolPartialCall performs a merge with any union data inside the MessageToolInvocation, using the provided MessageToolInvocationToolPartialCall
  560. func (t *MessageToolInvocation) MergeMessageToolInvocationToolPartialCall(v MessageToolInvocationToolPartialCall) error {
  561. v.State = "partial-call"
  562. b, err := json.Marshal(v)
  563. if err != nil {
  564. return err
  565. }
  566. merged, err := runtime.JSONMerge(t.union, b)
  567. t.union = merged
  568. return err
  569. }
  570. // AsMessageToolInvocationToolResult returns the union data inside the MessageToolInvocation as a MessageToolInvocationToolResult
  571. func (t MessageToolInvocation) AsMessageToolInvocationToolResult() (MessageToolInvocationToolResult, error) {
  572. var body MessageToolInvocationToolResult
  573. err := json.Unmarshal(t.union, &body)
  574. return body, err
  575. }
  576. // FromMessageToolInvocationToolResult overwrites any union data inside the MessageToolInvocation as the provided MessageToolInvocationToolResult
  577. func (t *MessageToolInvocation) FromMessageToolInvocationToolResult(v MessageToolInvocationToolResult) error {
  578. v.State = "result"
  579. b, err := json.Marshal(v)
  580. t.union = b
  581. return err
  582. }
  583. // MergeMessageToolInvocationToolResult performs a merge with any union data inside the MessageToolInvocation, using the provided MessageToolInvocationToolResult
  584. func (t *MessageToolInvocation) MergeMessageToolInvocationToolResult(v MessageToolInvocationToolResult) error {
  585. v.State = "result"
  586. b, err := json.Marshal(v)
  587. if err != nil {
  588. return err
  589. }
  590. merged, err := runtime.JSONMerge(t.union, b)
  591. t.union = merged
  592. return err
  593. }
  594. func (t MessageToolInvocation) Discriminator() (string, error) {
  595. var discriminator struct {
  596. Discriminator string `json:"state"`
  597. }
  598. err := json.Unmarshal(t.union, &discriminator)
  599. return discriminator.Discriminator, err
  600. }
  601. func (t MessageToolInvocation) ValueByDiscriminator() (interface{}, error) {
  602. discriminator, err := t.Discriminator()
  603. if err != nil {
  604. return nil, err
  605. }
  606. switch discriminator {
  607. case "call":
  608. return t.AsMessageToolInvocationToolCall()
  609. case "partial-call":
  610. return t.AsMessageToolInvocationToolPartialCall()
  611. case "result":
  612. return t.AsMessageToolInvocationToolResult()
  613. default:
  614. return nil, errors.New("unknown discriminator value: " + discriminator)
  615. }
  616. }
  617. func (t MessageToolInvocation) MarshalJSON() ([]byte, error) {
  618. b, err := t.union.MarshalJSON()
  619. return b, err
  620. }
  621. func (t *MessageToolInvocation) UnmarshalJSON(b []byte) error {
  622. err := t.union.UnmarshalJSON(b)
  623. return err
  624. }
  625. // RequestEditorFn is the function signature for the RequestEditor callback function
  626. type RequestEditorFn func(ctx context.Context, req *http.Request) error
  627. // Doer performs HTTP requests.
  628. //
  629. // The standard http.Client implements this interface.
  630. type HttpRequestDoer interface {
  631. Do(req *http.Request) (*http.Response, error)
  632. }
  633. // Client which conforms to the OpenAPI3 specification for this service.
  634. type Client struct {
  635. // The endpoint of the server conforming to this interface, with scheme,
  636. // https://api.deepmap.com for example. This can contain a path relative
  637. // to the server, such as https://api.deepmap.com/dev-test, and all the
  638. // paths in the swagger spec will be appended to the server.
  639. Server string
  640. // Doer for performing requests, typically a *http.Client with any
  641. // customized settings, such as certificate chains.
  642. Client HttpRequestDoer
  643. // A list of callbacks for modifying requests which are generated before sending over
  644. // the network.
  645. RequestEditors []RequestEditorFn
  646. }
  647. // ClientOption allows setting custom parameters during construction
  648. type ClientOption func(*Client) error
  649. // Creates a new Client, with reasonable defaults
  650. func NewClient(server string, opts ...ClientOption) (*Client, error) {
  651. // create a client with sane default values
  652. client := Client{
  653. Server: server,
  654. }
  655. // mutate client and add all optional params
  656. for _, o := range opts {
  657. if err := o(&client); err != nil {
  658. return nil, err
  659. }
  660. }
  661. // ensure the server URL always has a trailing slash
  662. if !strings.HasSuffix(client.Server, "/") {
  663. client.Server += "/"
  664. }
  665. // create httpClient, if not already present
  666. if client.Client == nil {
  667. client.Client = &http.Client{}
  668. }
  669. return &client, nil
  670. }
  671. // WithHTTPClient allows overriding the default Doer, which is
  672. // automatically created using http.Client. This is useful for tests.
  673. func WithHTTPClient(doer HttpRequestDoer) ClientOption {
  674. return func(c *Client) error {
  675. c.Client = doer
  676. return nil
  677. }
  678. }
  679. // WithRequestEditorFn allows setting up a callback function, which will be
  680. // called right before sending the request. This can be used to mutate the request.
  681. func WithRequestEditorFn(fn RequestEditorFn) ClientOption {
  682. return func(c *Client) error {
  683. c.RequestEditors = append(c.RequestEditors, fn)
  684. return nil
  685. }
  686. }
  687. // The interface specification for the client above.
  688. type ClientInterface interface {
  689. // GetEvent request
  690. GetEvent(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error)
  691. // PostProviderList request
  692. PostProviderList(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error)
  693. // PostSessionAbortWithBody request with any body
  694. PostSessionAbortWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error)
  695. PostSessionAbort(ctx context.Context, body PostSessionAbortJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error)
  696. // PostSessionChatWithBody request with any body
  697. PostSessionChatWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error)
  698. PostSessionChat(ctx context.Context, body PostSessionChatJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error)
  699. // PostSessionCreate request
  700. PostSessionCreate(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error)
  701. // PostSessionList request
  702. PostSessionList(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error)
  703. // PostSessionMessagesWithBody request with any body
  704. PostSessionMessagesWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error)
  705. PostSessionMessages(ctx context.Context, body PostSessionMessagesJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error)
  706. // PostSessionShareWithBody request with any body
  707. PostSessionShareWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error)
  708. PostSessionShare(ctx context.Context, body PostSessionShareJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error)
  709. // PostSessionSummarizeWithBody request with any body
  710. PostSessionSummarizeWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error)
  711. PostSessionSummarize(ctx context.Context, body PostSessionSummarizeJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error)
  712. }
  713. func (c *Client) GetEvent(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error) {
  714. req, err := NewGetEventRequest(c.Server)
  715. if err != nil {
  716. return nil, err
  717. }
  718. req = req.WithContext(ctx)
  719. if err := c.applyEditors(ctx, req, reqEditors); err != nil {
  720. return nil, err
  721. }
  722. return c.Client.Do(req)
  723. }
  724. func (c *Client) PostProviderList(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error) {
  725. req, err := NewPostProviderListRequest(c.Server)
  726. if err != nil {
  727. return nil, err
  728. }
  729. req = req.WithContext(ctx)
  730. if err := c.applyEditors(ctx, req, reqEditors); err != nil {
  731. return nil, err
  732. }
  733. return c.Client.Do(req)
  734. }
  735. func (c *Client) PostSessionAbortWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) {
  736. req, err := NewPostSessionAbortRequestWithBody(c.Server, contentType, body)
  737. if err != nil {
  738. return nil, err
  739. }
  740. req = req.WithContext(ctx)
  741. if err := c.applyEditors(ctx, req, reqEditors); err != nil {
  742. return nil, err
  743. }
  744. return c.Client.Do(req)
  745. }
  746. func (c *Client) PostSessionAbort(ctx context.Context, body PostSessionAbortJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) {
  747. req, err := NewPostSessionAbortRequest(c.Server, body)
  748. if err != nil {
  749. return nil, err
  750. }
  751. req = req.WithContext(ctx)
  752. if err := c.applyEditors(ctx, req, reqEditors); err != nil {
  753. return nil, err
  754. }
  755. return c.Client.Do(req)
  756. }
  757. func (c *Client) PostSessionChatWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) {
  758. req, err := NewPostSessionChatRequestWithBody(c.Server, contentType, body)
  759. if err != nil {
  760. return nil, err
  761. }
  762. req = req.WithContext(ctx)
  763. if err := c.applyEditors(ctx, req, reqEditors); err != nil {
  764. return nil, err
  765. }
  766. return c.Client.Do(req)
  767. }
  768. func (c *Client) PostSessionChat(ctx context.Context, body PostSessionChatJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) {
  769. req, err := NewPostSessionChatRequest(c.Server, body)
  770. if err != nil {
  771. return nil, err
  772. }
  773. req = req.WithContext(ctx)
  774. if err := c.applyEditors(ctx, req, reqEditors); err != nil {
  775. return nil, err
  776. }
  777. return c.Client.Do(req)
  778. }
  779. func (c *Client) PostSessionCreate(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error) {
  780. req, err := NewPostSessionCreateRequest(c.Server)
  781. if err != nil {
  782. return nil, err
  783. }
  784. req = req.WithContext(ctx)
  785. if err := c.applyEditors(ctx, req, reqEditors); err != nil {
  786. return nil, err
  787. }
  788. return c.Client.Do(req)
  789. }
  790. func (c *Client) PostSessionList(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error) {
  791. req, err := NewPostSessionListRequest(c.Server)
  792. if err != nil {
  793. return nil, err
  794. }
  795. req = req.WithContext(ctx)
  796. if err := c.applyEditors(ctx, req, reqEditors); err != nil {
  797. return nil, err
  798. }
  799. return c.Client.Do(req)
  800. }
  801. func (c *Client) PostSessionMessagesWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) {
  802. req, err := NewPostSessionMessagesRequestWithBody(c.Server, contentType, body)
  803. if err != nil {
  804. return nil, err
  805. }
  806. req = req.WithContext(ctx)
  807. if err := c.applyEditors(ctx, req, reqEditors); err != nil {
  808. return nil, err
  809. }
  810. return c.Client.Do(req)
  811. }
  812. func (c *Client) PostSessionMessages(ctx context.Context, body PostSessionMessagesJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) {
  813. req, err := NewPostSessionMessagesRequest(c.Server, body)
  814. if err != nil {
  815. return nil, err
  816. }
  817. req = req.WithContext(ctx)
  818. if err := c.applyEditors(ctx, req, reqEditors); err != nil {
  819. return nil, err
  820. }
  821. return c.Client.Do(req)
  822. }
  823. func (c *Client) PostSessionShareWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) {
  824. req, err := NewPostSessionShareRequestWithBody(c.Server, contentType, body)
  825. if err != nil {
  826. return nil, err
  827. }
  828. req = req.WithContext(ctx)
  829. if err := c.applyEditors(ctx, req, reqEditors); err != nil {
  830. return nil, err
  831. }
  832. return c.Client.Do(req)
  833. }
  834. func (c *Client) PostSessionShare(ctx context.Context, body PostSessionShareJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) {
  835. req, err := NewPostSessionShareRequest(c.Server, body)
  836. if err != nil {
  837. return nil, err
  838. }
  839. req = req.WithContext(ctx)
  840. if err := c.applyEditors(ctx, req, reqEditors); err != nil {
  841. return nil, err
  842. }
  843. return c.Client.Do(req)
  844. }
  845. func (c *Client) PostSessionSummarizeWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) {
  846. req, err := NewPostSessionSummarizeRequestWithBody(c.Server, contentType, body)
  847. if err != nil {
  848. return nil, err
  849. }
  850. req = req.WithContext(ctx)
  851. if err := c.applyEditors(ctx, req, reqEditors); err != nil {
  852. return nil, err
  853. }
  854. return c.Client.Do(req)
  855. }
  856. func (c *Client) PostSessionSummarize(ctx context.Context, body PostSessionSummarizeJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) {
  857. req, err := NewPostSessionSummarizeRequest(c.Server, body)
  858. if err != nil {
  859. return nil, err
  860. }
  861. req = req.WithContext(ctx)
  862. if err := c.applyEditors(ctx, req, reqEditors); err != nil {
  863. return nil, err
  864. }
  865. return c.Client.Do(req)
  866. }
  867. // NewGetEventRequest generates requests for GetEvent
  868. func NewGetEventRequest(server string) (*http.Request, error) {
  869. var err error
  870. serverURL, err := url.Parse(server)
  871. if err != nil {
  872. return nil, err
  873. }
  874. operationPath := fmt.Sprintf("/event")
  875. if operationPath[0] == '/' {
  876. operationPath = "." + operationPath
  877. }
  878. queryURL, err := serverURL.Parse(operationPath)
  879. if err != nil {
  880. return nil, err
  881. }
  882. req, err := http.NewRequest("GET", queryURL.String(), nil)
  883. if err != nil {
  884. return nil, err
  885. }
  886. return req, nil
  887. }
  888. // NewPostProviderListRequest generates requests for PostProviderList
  889. func NewPostProviderListRequest(server string) (*http.Request, error) {
  890. var err error
  891. serverURL, err := url.Parse(server)
  892. if err != nil {
  893. return nil, err
  894. }
  895. operationPath := fmt.Sprintf("/provider_list")
  896. if operationPath[0] == '/' {
  897. operationPath = "." + operationPath
  898. }
  899. queryURL, err := serverURL.Parse(operationPath)
  900. if err != nil {
  901. return nil, err
  902. }
  903. req, err := http.NewRequest("POST", queryURL.String(), nil)
  904. if err != nil {
  905. return nil, err
  906. }
  907. return req, nil
  908. }
  909. // NewPostSessionAbortRequest calls the generic PostSessionAbort builder with application/json body
  910. func NewPostSessionAbortRequest(server string, body PostSessionAbortJSONRequestBody) (*http.Request, error) {
  911. var bodyReader io.Reader
  912. buf, err := json.Marshal(body)
  913. if err != nil {
  914. return nil, err
  915. }
  916. bodyReader = bytes.NewReader(buf)
  917. return NewPostSessionAbortRequestWithBody(server, "application/json", bodyReader)
  918. }
  919. // NewPostSessionAbortRequestWithBody generates requests for PostSessionAbort with any type of body
  920. func NewPostSessionAbortRequestWithBody(server string, contentType string, body io.Reader) (*http.Request, error) {
  921. var err error
  922. serverURL, err := url.Parse(server)
  923. if err != nil {
  924. return nil, err
  925. }
  926. operationPath := fmt.Sprintf("/session_abort")
  927. if operationPath[0] == '/' {
  928. operationPath = "." + operationPath
  929. }
  930. queryURL, err := serverURL.Parse(operationPath)
  931. if err != nil {
  932. return nil, err
  933. }
  934. req, err := http.NewRequest("POST", queryURL.String(), body)
  935. if err != nil {
  936. return nil, err
  937. }
  938. req.Header.Add("Content-Type", contentType)
  939. return req, nil
  940. }
  941. // NewPostSessionChatRequest calls the generic PostSessionChat builder with application/json body
  942. func NewPostSessionChatRequest(server string, body PostSessionChatJSONRequestBody) (*http.Request, error) {
  943. var bodyReader io.Reader
  944. buf, err := json.Marshal(body)
  945. if err != nil {
  946. return nil, err
  947. }
  948. bodyReader = bytes.NewReader(buf)
  949. return NewPostSessionChatRequestWithBody(server, "application/json", bodyReader)
  950. }
  951. // NewPostSessionChatRequestWithBody generates requests for PostSessionChat with any type of body
  952. func NewPostSessionChatRequestWithBody(server string, contentType string, body io.Reader) (*http.Request, error) {
  953. var err error
  954. serverURL, err := url.Parse(server)
  955. if err != nil {
  956. return nil, err
  957. }
  958. operationPath := fmt.Sprintf("/session_chat")
  959. if operationPath[0] == '/' {
  960. operationPath = "." + operationPath
  961. }
  962. queryURL, err := serverURL.Parse(operationPath)
  963. if err != nil {
  964. return nil, err
  965. }
  966. req, err := http.NewRequest("POST", queryURL.String(), body)
  967. if err != nil {
  968. return nil, err
  969. }
  970. req.Header.Add("Content-Type", contentType)
  971. return req, nil
  972. }
  973. // NewPostSessionCreateRequest generates requests for PostSessionCreate
  974. func NewPostSessionCreateRequest(server string) (*http.Request, error) {
  975. var err error
  976. serverURL, err := url.Parse(server)
  977. if err != nil {
  978. return nil, err
  979. }
  980. operationPath := fmt.Sprintf("/session_create")
  981. if operationPath[0] == '/' {
  982. operationPath = "." + operationPath
  983. }
  984. queryURL, err := serverURL.Parse(operationPath)
  985. if err != nil {
  986. return nil, err
  987. }
  988. req, err := http.NewRequest("POST", queryURL.String(), nil)
  989. if err != nil {
  990. return nil, err
  991. }
  992. return req, nil
  993. }
  994. // NewPostSessionListRequest generates requests for PostSessionList
  995. func NewPostSessionListRequest(server string) (*http.Request, error) {
  996. var err error
  997. serverURL, err := url.Parse(server)
  998. if err != nil {
  999. return nil, err
  1000. }
  1001. operationPath := fmt.Sprintf("/session_list")
  1002. if operationPath[0] == '/' {
  1003. operationPath = "." + operationPath
  1004. }
  1005. queryURL, err := serverURL.Parse(operationPath)
  1006. if err != nil {
  1007. return nil, err
  1008. }
  1009. req, err := http.NewRequest("POST", queryURL.String(), nil)
  1010. if err != nil {
  1011. return nil, err
  1012. }
  1013. return req, nil
  1014. }
  1015. // NewPostSessionMessagesRequest calls the generic PostSessionMessages builder with application/json body
  1016. func NewPostSessionMessagesRequest(server string, body PostSessionMessagesJSONRequestBody) (*http.Request, error) {
  1017. var bodyReader io.Reader
  1018. buf, err := json.Marshal(body)
  1019. if err != nil {
  1020. return nil, err
  1021. }
  1022. bodyReader = bytes.NewReader(buf)
  1023. return NewPostSessionMessagesRequestWithBody(server, "application/json", bodyReader)
  1024. }
  1025. // NewPostSessionMessagesRequestWithBody generates requests for PostSessionMessages with any type of body
  1026. func NewPostSessionMessagesRequestWithBody(server string, contentType string, body io.Reader) (*http.Request, error) {
  1027. var err error
  1028. serverURL, err := url.Parse(server)
  1029. if err != nil {
  1030. return nil, err
  1031. }
  1032. operationPath := fmt.Sprintf("/session_messages")
  1033. if operationPath[0] == '/' {
  1034. operationPath = "." + operationPath
  1035. }
  1036. queryURL, err := serverURL.Parse(operationPath)
  1037. if err != nil {
  1038. return nil, err
  1039. }
  1040. req, err := http.NewRequest("POST", queryURL.String(), body)
  1041. if err != nil {
  1042. return nil, err
  1043. }
  1044. req.Header.Add("Content-Type", contentType)
  1045. return req, nil
  1046. }
  1047. // NewPostSessionShareRequest calls the generic PostSessionShare builder with application/json body
  1048. func NewPostSessionShareRequest(server string, body PostSessionShareJSONRequestBody) (*http.Request, error) {
  1049. var bodyReader io.Reader
  1050. buf, err := json.Marshal(body)
  1051. if err != nil {
  1052. return nil, err
  1053. }
  1054. bodyReader = bytes.NewReader(buf)
  1055. return NewPostSessionShareRequestWithBody(server, "application/json", bodyReader)
  1056. }
  1057. // NewPostSessionShareRequestWithBody generates requests for PostSessionShare with any type of body
  1058. func NewPostSessionShareRequestWithBody(server string, contentType string, body io.Reader) (*http.Request, error) {
  1059. var err error
  1060. serverURL, err := url.Parse(server)
  1061. if err != nil {
  1062. return nil, err
  1063. }
  1064. operationPath := fmt.Sprintf("/session_share")
  1065. if operationPath[0] == '/' {
  1066. operationPath = "." + operationPath
  1067. }
  1068. queryURL, err := serverURL.Parse(operationPath)
  1069. if err != nil {
  1070. return nil, err
  1071. }
  1072. req, err := http.NewRequest("POST", queryURL.String(), body)
  1073. if err != nil {
  1074. return nil, err
  1075. }
  1076. req.Header.Add("Content-Type", contentType)
  1077. return req, nil
  1078. }
  1079. // NewPostSessionSummarizeRequest calls the generic PostSessionSummarize builder with application/json body
  1080. func NewPostSessionSummarizeRequest(server string, body PostSessionSummarizeJSONRequestBody) (*http.Request, error) {
  1081. var bodyReader io.Reader
  1082. buf, err := json.Marshal(body)
  1083. if err != nil {
  1084. return nil, err
  1085. }
  1086. bodyReader = bytes.NewReader(buf)
  1087. return NewPostSessionSummarizeRequestWithBody(server, "application/json", bodyReader)
  1088. }
  1089. // NewPostSessionSummarizeRequestWithBody generates requests for PostSessionSummarize with any type of body
  1090. func NewPostSessionSummarizeRequestWithBody(server string, contentType string, body io.Reader) (*http.Request, error) {
  1091. var err error
  1092. serverURL, err := url.Parse(server)
  1093. if err != nil {
  1094. return nil, err
  1095. }
  1096. operationPath := fmt.Sprintf("/session_summarize")
  1097. if operationPath[0] == '/' {
  1098. operationPath = "." + operationPath
  1099. }
  1100. queryURL, err := serverURL.Parse(operationPath)
  1101. if err != nil {
  1102. return nil, err
  1103. }
  1104. req, err := http.NewRequest("POST", queryURL.String(), body)
  1105. if err != nil {
  1106. return nil, err
  1107. }
  1108. req.Header.Add("Content-Type", contentType)
  1109. return req, nil
  1110. }
  1111. func (c *Client) applyEditors(ctx context.Context, req *http.Request, additionalEditors []RequestEditorFn) error {
  1112. for _, r := range c.RequestEditors {
  1113. if err := r(ctx, req); err != nil {
  1114. return err
  1115. }
  1116. }
  1117. for _, r := range additionalEditors {
  1118. if err := r(ctx, req); err != nil {
  1119. return err
  1120. }
  1121. }
  1122. return nil
  1123. }
  1124. // ClientWithResponses builds on ClientInterface to offer response payloads
  1125. type ClientWithResponses struct {
  1126. ClientInterface
  1127. }
  1128. // NewClientWithResponses creates a new ClientWithResponses, which wraps
  1129. // Client with return type handling
  1130. func NewClientWithResponses(server string, opts ...ClientOption) (*ClientWithResponses, error) {
  1131. client, err := NewClient(server, opts...)
  1132. if err != nil {
  1133. return nil, err
  1134. }
  1135. return &ClientWithResponses{client}, nil
  1136. }
  1137. // WithBaseURL overrides the baseURL.
  1138. func WithBaseURL(baseURL string) ClientOption {
  1139. return func(c *Client) error {
  1140. newBaseURL, err := url.Parse(baseURL)
  1141. if err != nil {
  1142. return err
  1143. }
  1144. c.Server = newBaseURL.String()
  1145. return nil
  1146. }
  1147. }
  1148. // ClientWithResponsesInterface is the interface specification for the client with responses above.
  1149. type ClientWithResponsesInterface interface {
  1150. // GetEventWithResponse request
  1151. GetEventWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*GetEventResponse, error)
  1152. // PostProviderListWithResponse request
  1153. PostProviderListWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*PostProviderListResponse, error)
  1154. // PostSessionAbortWithBodyWithResponse request with any body
  1155. PostSessionAbortWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*PostSessionAbortResponse, error)
  1156. PostSessionAbortWithResponse(ctx context.Context, body PostSessionAbortJSONRequestBody, reqEditors ...RequestEditorFn) (*PostSessionAbortResponse, error)
  1157. // PostSessionChatWithBodyWithResponse request with any body
  1158. PostSessionChatWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*PostSessionChatResponse, error)
  1159. PostSessionChatWithResponse(ctx context.Context, body PostSessionChatJSONRequestBody, reqEditors ...RequestEditorFn) (*PostSessionChatResponse, error)
  1160. // PostSessionCreateWithResponse request
  1161. PostSessionCreateWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*PostSessionCreateResponse, error)
  1162. // PostSessionListWithResponse request
  1163. PostSessionListWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*PostSessionListResponse, error)
  1164. // PostSessionMessagesWithBodyWithResponse request with any body
  1165. PostSessionMessagesWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*PostSessionMessagesResponse, error)
  1166. PostSessionMessagesWithResponse(ctx context.Context, body PostSessionMessagesJSONRequestBody, reqEditors ...RequestEditorFn) (*PostSessionMessagesResponse, error)
  1167. // PostSessionShareWithBodyWithResponse request with any body
  1168. PostSessionShareWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*PostSessionShareResponse, error)
  1169. PostSessionShareWithResponse(ctx context.Context, body PostSessionShareJSONRequestBody, reqEditors ...RequestEditorFn) (*PostSessionShareResponse, error)
  1170. // PostSessionSummarizeWithBodyWithResponse request with any body
  1171. PostSessionSummarizeWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*PostSessionSummarizeResponse, error)
  1172. PostSessionSummarizeWithResponse(ctx context.Context, body PostSessionSummarizeJSONRequestBody, reqEditors ...RequestEditorFn) (*PostSessionSummarizeResponse, error)
  1173. }
  1174. type GetEventResponse struct {
  1175. Body []byte
  1176. HTTPResponse *http.Response
  1177. JSON200 *Event
  1178. }
  1179. // Status returns HTTPResponse.Status
  1180. func (r GetEventResponse) Status() string {
  1181. if r.HTTPResponse != nil {
  1182. return r.HTTPResponse.Status
  1183. }
  1184. return http.StatusText(0)
  1185. }
  1186. // StatusCode returns HTTPResponse.StatusCode
  1187. func (r GetEventResponse) StatusCode() int {
  1188. if r.HTTPResponse != nil {
  1189. return r.HTTPResponse.StatusCode
  1190. }
  1191. return 0
  1192. }
  1193. type PostProviderListResponse struct {
  1194. Body []byte
  1195. HTTPResponse *http.Response
  1196. JSON200 *map[string]ProviderInfo
  1197. }
  1198. // Status returns HTTPResponse.Status
  1199. func (r PostProviderListResponse) Status() string {
  1200. if r.HTTPResponse != nil {
  1201. return r.HTTPResponse.Status
  1202. }
  1203. return http.StatusText(0)
  1204. }
  1205. // StatusCode returns HTTPResponse.StatusCode
  1206. func (r PostProviderListResponse) StatusCode() int {
  1207. if r.HTTPResponse != nil {
  1208. return r.HTTPResponse.StatusCode
  1209. }
  1210. return 0
  1211. }
  1212. type PostSessionAbortResponse struct {
  1213. Body []byte
  1214. HTTPResponse *http.Response
  1215. JSON200 *bool
  1216. }
  1217. // Status returns HTTPResponse.Status
  1218. func (r PostSessionAbortResponse) Status() string {
  1219. if r.HTTPResponse != nil {
  1220. return r.HTTPResponse.Status
  1221. }
  1222. return http.StatusText(0)
  1223. }
  1224. // StatusCode returns HTTPResponse.StatusCode
  1225. func (r PostSessionAbortResponse) StatusCode() int {
  1226. if r.HTTPResponse != nil {
  1227. return r.HTTPResponse.StatusCode
  1228. }
  1229. return 0
  1230. }
  1231. type PostSessionChatResponse struct {
  1232. Body []byte
  1233. HTTPResponse *http.Response
  1234. JSON200 *MessageInfo
  1235. }
  1236. // Status returns HTTPResponse.Status
  1237. func (r PostSessionChatResponse) Status() string {
  1238. if r.HTTPResponse != nil {
  1239. return r.HTTPResponse.Status
  1240. }
  1241. return http.StatusText(0)
  1242. }
  1243. // StatusCode returns HTTPResponse.StatusCode
  1244. func (r PostSessionChatResponse) StatusCode() int {
  1245. if r.HTTPResponse != nil {
  1246. return r.HTTPResponse.StatusCode
  1247. }
  1248. return 0
  1249. }
  1250. type PostSessionCreateResponse struct {
  1251. Body []byte
  1252. HTTPResponse *http.Response
  1253. JSON200 *SessionInfo
  1254. }
  1255. // Status returns HTTPResponse.Status
  1256. func (r PostSessionCreateResponse) Status() string {
  1257. if r.HTTPResponse != nil {
  1258. return r.HTTPResponse.Status
  1259. }
  1260. return http.StatusText(0)
  1261. }
  1262. // StatusCode returns HTTPResponse.StatusCode
  1263. func (r PostSessionCreateResponse) StatusCode() int {
  1264. if r.HTTPResponse != nil {
  1265. return r.HTTPResponse.StatusCode
  1266. }
  1267. return 0
  1268. }
  1269. type PostSessionListResponse struct {
  1270. Body []byte
  1271. HTTPResponse *http.Response
  1272. JSON200 *[]SessionInfo
  1273. }
  1274. // Status returns HTTPResponse.Status
  1275. func (r PostSessionListResponse) Status() string {
  1276. if r.HTTPResponse != nil {
  1277. return r.HTTPResponse.Status
  1278. }
  1279. return http.StatusText(0)
  1280. }
  1281. // StatusCode returns HTTPResponse.StatusCode
  1282. func (r PostSessionListResponse) StatusCode() int {
  1283. if r.HTTPResponse != nil {
  1284. return r.HTTPResponse.StatusCode
  1285. }
  1286. return 0
  1287. }
  1288. type PostSessionMessagesResponse struct {
  1289. Body []byte
  1290. HTTPResponse *http.Response
  1291. JSON200 *[]MessageInfo
  1292. }
  1293. // Status returns HTTPResponse.Status
  1294. func (r PostSessionMessagesResponse) Status() string {
  1295. if r.HTTPResponse != nil {
  1296. return r.HTTPResponse.Status
  1297. }
  1298. return http.StatusText(0)
  1299. }
  1300. // StatusCode returns HTTPResponse.StatusCode
  1301. func (r PostSessionMessagesResponse) StatusCode() int {
  1302. if r.HTTPResponse != nil {
  1303. return r.HTTPResponse.StatusCode
  1304. }
  1305. return 0
  1306. }
  1307. type PostSessionShareResponse struct {
  1308. Body []byte
  1309. HTTPResponse *http.Response
  1310. JSON200 *SessionInfo
  1311. }
  1312. // Status returns HTTPResponse.Status
  1313. func (r PostSessionShareResponse) Status() string {
  1314. if r.HTTPResponse != nil {
  1315. return r.HTTPResponse.Status
  1316. }
  1317. return http.StatusText(0)
  1318. }
  1319. // StatusCode returns HTTPResponse.StatusCode
  1320. func (r PostSessionShareResponse) StatusCode() int {
  1321. if r.HTTPResponse != nil {
  1322. return r.HTTPResponse.StatusCode
  1323. }
  1324. return 0
  1325. }
  1326. type PostSessionSummarizeResponse struct {
  1327. Body []byte
  1328. HTTPResponse *http.Response
  1329. JSON200 *bool
  1330. }
  1331. // Status returns HTTPResponse.Status
  1332. func (r PostSessionSummarizeResponse) Status() string {
  1333. if r.HTTPResponse != nil {
  1334. return r.HTTPResponse.Status
  1335. }
  1336. return http.StatusText(0)
  1337. }
  1338. // StatusCode returns HTTPResponse.StatusCode
  1339. func (r PostSessionSummarizeResponse) StatusCode() int {
  1340. if r.HTTPResponse != nil {
  1341. return r.HTTPResponse.StatusCode
  1342. }
  1343. return 0
  1344. }
  1345. // GetEventWithResponse request returning *GetEventResponse
  1346. func (c *ClientWithResponses) GetEventWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*GetEventResponse, error) {
  1347. rsp, err := c.GetEvent(ctx, reqEditors...)
  1348. if err != nil {
  1349. return nil, err
  1350. }
  1351. return ParseGetEventResponse(rsp)
  1352. }
  1353. // PostProviderListWithResponse request returning *PostProviderListResponse
  1354. func (c *ClientWithResponses) PostProviderListWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*PostProviderListResponse, error) {
  1355. rsp, err := c.PostProviderList(ctx, reqEditors...)
  1356. if err != nil {
  1357. return nil, err
  1358. }
  1359. return ParsePostProviderListResponse(rsp)
  1360. }
  1361. // PostSessionAbortWithBodyWithResponse request with arbitrary body returning *PostSessionAbortResponse
  1362. func (c *ClientWithResponses) PostSessionAbortWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*PostSessionAbortResponse, error) {
  1363. rsp, err := c.PostSessionAbortWithBody(ctx, contentType, body, reqEditors...)
  1364. if err != nil {
  1365. return nil, err
  1366. }
  1367. return ParsePostSessionAbortResponse(rsp)
  1368. }
  1369. func (c *ClientWithResponses) PostSessionAbortWithResponse(ctx context.Context, body PostSessionAbortJSONRequestBody, reqEditors ...RequestEditorFn) (*PostSessionAbortResponse, error) {
  1370. rsp, err := c.PostSessionAbort(ctx, body, reqEditors...)
  1371. if err != nil {
  1372. return nil, err
  1373. }
  1374. return ParsePostSessionAbortResponse(rsp)
  1375. }
  1376. // PostSessionChatWithBodyWithResponse request with arbitrary body returning *PostSessionChatResponse
  1377. func (c *ClientWithResponses) PostSessionChatWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*PostSessionChatResponse, error) {
  1378. rsp, err := c.PostSessionChatWithBody(ctx, contentType, body, reqEditors...)
  1379. if err != nil {
  1380. return nil, err
  1381. }
  1382. return ParsePostSessionChatResponse(rsp)
  1383. }
  1384. func (c *ClientWithResponses) PostSessionChatWithResponse(ctx context.Context, body PostSessionChatJSONRequestBody, reqEditors ...RequestEditorFn) (*PostSessionChatResponse, error) {
  1385. rsp, err := c.PostSessionChat(ctx, body, reqEditors...)
  1386. if err != nil {
  1387. return nil, err
  1388. }
  1389. return ParsePostSessionChatResponse(rsp)
  1390. }
  1391. // PostSessionCreateWithResponse request returning *PostSessionCreateResponse
  1392. func (c *ClientWithResponses) PostSessionCreateWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*PostSessionCreateResponse, error) {
  1393. rsp, err := c.PostSessionCreate(ctx, reqEditors...)
  1394. if err != nil {
  1395. return nil, err
  1396. }
  1397. return ParsePostSessionCreateResponse(rsp)
  1398. }
  1399. // PostSessionListWithResponse request returning *PostSessionListResponse
  1400. func (c *ClientWithResponses) PostSessionListWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*PostSessionListResponse, error) {
  1401. rsp, err := c.PostSessionList(ctx, reqEditors...)
  1402. if err != nil {
  1403. return nil, err
  1404. }
  1405. return ParsePostSessionListResponse(rsp)
  1406. }
  1407. // PostSessionMessagesWithBodyWithResponse request with arbitrary body returning *PostSessionMessagesResponse
  1408. func (c *ClientWithResponses) PostSessionMessagesWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*PostSessionMessagesResponse, error) {
  1409. rsp, err := c.PostSessionMessagesWithBody(ctx, contentType, body, reqEditors...)
  1410. if err != nil {
  1411. return nil, err
  1412. }
  1413. return ParsePostSessionMessagesResponse(rsp)
  1414. }
  1415. func (c *ClientWithResponses) PostSessionMessagesWithResponse(ctx context.Context, body PostSessionMessagesJSONRequestBody, reqEditors ...RequestEditorFn) (*PostSessionMessagesResponse, error) {
  1416. rsp, err := c.PostSessionMessages(ctx, body, reqEditors...)
  1417. if err != nil {
  1418. return nil, err
  1419. }
  1420. return ParsePostSessionMessagesResponse(rsp)
  1421. }
  1422. // PostSessionShareWithBodyWithResponse request with arbitrary body returning *PostSessionShareResponse
  1423. func (c *ClientWithResponses) PostSessionShareWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*PostSessionShareResponse, error) {
  1424. rsp, err := c.PostSessionShareWithBody(ctx, contentType, body, reqEditors...)
  1425. if err != nil {
  1426. return nil, err
  1427. }
  1428. return ParsePostSessionShareResponse(rsp)
  1429. }
  1430. func (c *ClientWithResponses) PostSessionShareWithResponse(ctx context.Context, body PostSessionShareJSONRequestBody, reqEditors ...RequestEditorFn) (*PostSessionShareResponse, error) {
  1431. rsp, err := c.PostSessionShare(ctx, body, reqEditors...)
  1432. if err != nil {
  1433. return nil, err
  1434. }
  1435. return ParsePostSessionShareResponse(rsp)
  1436. }
  1437. // PostSessionSummarizeWithBodyWithResponse request with arbitrary body returning *PostSessionSummarizeResponse
  1438. func (c *ClientWithResponses) PostSessionSummarizeWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*PostSessionSummarizeResponse, error) {
  1439. rsp, err := c.PostSessionSummarizeWithBody(ctx, contentType, body, reqEditors...)
  1440. if err != nil {
  1441. return nil, err
  1442. }
  1443. return ParsePostSessionSummarizeResponse(rsp)
  1444. }
  1445. func (c *ClientWithResponses) PostSessionSummarizeWithResponse(ctx context.Context, body PostSessionSummarizeJSONRequestBody, reqEditors ...RequestEditorFn) (*PostSessionSummarizeResponse, error) {
  1446. rsp, err := c.PostSessionSummarize(ctx, body, reqEditors...)
  1447. if err != nil {
  1448. return nil, err
  1449. }
  1450. return ParsePostSessionSummarizeResponse(rsp)
  1451. }
  1452. // ParseGetEventResponse parses an HTTP response from a GetEventWithResponse call
  1453. func ParseGetEventResponse(rsp *http.Response) (*GetEventResponse, error) {
  1454. bodyBytes, err := io.ReadAll(rsp.Body)
  1455. defer func() { _ = rsp.Body.Close() }()
  1456. if err != nil {
  1457. return nil, err
  1458. }
  1459. response := &GetEventResponse{
  1460. Body: bodyBytes,
  1461. HTTPResponse: rsp,
  1462. }
  1463. switch {
  1464. case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200:
  1465. var dest Event
  1466. if err := json.Unmarshal(bodyBytes, &dest); err != nil {
  1467. return nil, err
  1468. }
  1469. response.JSON200 = &dest
  1470. }
  1471. return response, nil
  1472. }
  1473. // ParsePostProviderListResponse parses an HTTP response from a PostProviderListWithResponse call
  1474. func ParsePostProviderListResponse(rsp *http.Response) (*PostProviderListResponse, error) {
  1475. bodyBytes, err := io.ReadAll(rsp.Body)
  1476. defer func() { _ = rsp.Body.Close() }()
  1477. if err != nil {
  1478. return nil, err
  1479. }
  1480. response := &PostProviderListResponse{
  1481. Body: bodyBytes,
  1482. HTTPResponse: rsp,
  1483. }
  1484. switch {
  1485. case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200:
  1486. var dest map[string]ProviderInfo
  1487. if err := json.Unmarshal(bodyBytes, &dest); err != nil {
  1488. return nil, err
  1489. }
  1490. response.JSON200 = &dest
  1491. }
  1492. return response, nil
  1493. }
  1494. // ParsePostSessionAbortResponse parses an HTTP response from a PostSessionAbortWithResponse call
  1495. func ParsePostSessionAbortResponse(rsp *http.Response) (*PostSessionAbortResponse, error) {
  1496. bodyBytes, err := io.ReadAll(rsp.Body)
  1497. defer func() { _ = rsp.Body.Close() }()
  1498. if err != nil {
  1499. return nil, err
  1500. }
  1501. response := &PostSessionAbortResponse{
  1502. Body: bodyBytes,
  1503. HTTPResponse: rsp,
  1504. }
  1505. switch {
  1506. case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200:
  1507. var dest bool
  1508. if err := json.Unmarshal(bodyBytes, &dest); err != nil {
  1509. return nil, err
  1510. }
  1511. response.JSON200 = &dest
  1512. }
  1513. return response, nil
  1514. }
  1515. // ParsePostSessionChatResponse parses an HTTP response from a PostSessionChatWithResponse call
  1516. func ParsePostSessionChatResponse(rsp *http.Response) (*PostSessionChatResponse, error) {
  1517. bodyBytes, err := io.ReadAll(rsp.Body)
  1518. defer func() { _ = rsp.Body.Close() }()
  1519. if err != nil {
  1520. return nil, err
  1521. }
  1522. response := &PostSessionChatResponse{
  1523. Body: bodyBytes,
  1524. HTTPResponse: rsp,
  1525. }
  1526. switch {
  1527. case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200:
  1528. var dest MessageInfo
  1529. if err := json.Unmarshal(bodyBytes, &dest); err != nil {
  1530. return nil, err
  1531. }
  1532. response.JSON200 = &dest
  1533. }
  1534. return response, nil
  1535. }
  1536. // ParsePostSessionCreateResponse parses an HTTP response from a PostSessionCreateWithResponse call
  1537. func ParsePostSessionCreateResponse(rsp *http.Response) (*PostSessionCreateResponse, error) {
  1538. bodyBytes, err := io.ReadAll(rsp.Body)
  1539. defer func() { _ = rsp.Body.Close() }()
  1540. if err != nil {
  1541. return nil, err
  1542. }
  1543. response := &PostSessionCreateResponse{
  1544. Body: bodyBytes,
  1545. HTTPResponse: rsp,
  1546. }
  1547. switch {
  1548. case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200:
  1549. var dest SessionInfo
  1550. if err := json.Unmarshal(bodyBytes, &dest); err != nil {
  1551. return nil, err
  1552. }
  1553. response.JSON200 = &dest
  1554. }
  1555. return response, nil
  1556. }
  1557. // ParsePostSessionListResponse parses an HTTP response from a PostSessionListWithResponse call
  1558. func ParsePostSessionListResponse(rsp *http.Response) (*PostSessionListResponse, error) {
  1559. bodyBytes, err := io.ReadAll(rsp.Body)
  1560. defer func() { _ = rsp.Body.Close() }()
  1561. if err != nil {
  1562. return nil, err
  1563. }
  1564. response := &PostSessionListResponse{
  1565. Body: bodyBytes,
  1566. HTTPResponse: rsp,
  1567. }
  1568. switch {
  1569. case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200:
  1570. var dest []SessionInfo
  1571. if err := json.Unmarshal(bodyBytes, &dest); err != nil {
  1572. return nil, err
  1573. }
  1574. response.JSON200 = &dest
  1575. }
  1576. return response, nil
  1577. }
  1578. // ParsePostSessionMessagesResponse parses an HTTP response from a PostSessionMessagesWithResponse call
  1579. func ParsePostSessionMessagesResponse(rsp *http.Response) (*PostSessionMessagesResponse, error) {
  1580. bodyBytes, err := io.ReadAll(rsp.Body)
  1581. defer func() { _ = rsp.Body.Close() }()
  1582. if err != nil {
  1583. return nil, err
  1584. }
  1585. response := &PostSessionMessagesResponse{
  1586. Body: bodyBytes,
  1587. HTTPResponse: rsp,
  1588. }
  1589. switch {
  1590. case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200:
  1591. var dest []MessageInfo
  1592. if err := json.Unmarshal(bodyBytes, &dest); err != nil {
  1593. return nil, err
  1594. }
  1595. response.JSON200 = &dest
  1596. }
  1597. return response, nil
  1598. }
  1599. // ParsePostSessionShareResponse parses an HTTP response from a PostSessionShareWithResponse call
  1600. func ParsePostSessionShareResponse(rsp *http.Response) (*PostSessionShareResponse, error) {
  1601. bodyBytes, err := io.ReadAll(rsp.Body)
  1602. defer func() { _ = rsp.Body.Close() }()
  1603. if err != nil {
  1604. return nil, err
  1605. }
  1606. response := &PostSessionShareResponse{
  1607. Body: bodyBytes,
  1608. HTTPResponse: rsp,
  1609. }
  1610. switch {
  1611. case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200:
  1612. var dest SessionInfo
  1613. if err := json.Unmarshal(bodyBytes, &dest); err != nil {
  1614. return nil, err
  1615. }
  1616. response.JSON200 = &dest
  1617. }
  1618. return response, nil
  1619. }
  1620. // ParsePostSessionSummarizeResponse parses an HTTP response from a PostSessionSummarizeWithResponse call
  1621. func ParsePostSessionSummarizeResponse(rsp *http.Response) (*PostSessionSummarizeResponse, error) {
  1622. bodyBytes, err := io.ReadAll(rsp.Body)
  1623. defer func() { _ = rsp.Body.Close() }()
  1624. if err != nil {
  1625. return nil, err
  1626. }
  1627. response := &PostSessionSummarizeResponse{
  1628. Body: bodyBytes,
  1629. HTTPResponse: rsp,
  1630. }
  1631. switch {
  1632. case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200:
  1633. var dest bool
  1634. if err := json.Unmarshal(bodyBytes, &dest); err != nil {
  1635. return nil, err
  1636. }
  1637. response.JSON200 = &dest
  1638. }
  1639. return response, nil
  1640. }