generated-client.go 59 KB

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