generated-client.go 54 KB

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