generated-client.go 54 KB

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