generated-client.go 54 KB

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