generated-client.go 66 KB

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