generated-client.go 63 KB

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