generated-client.go 59 KB

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