generated-client.go 47 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498
  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 SessionMessageRole.
  18. const (
  19. Assistant SessionMessageRole = "assistant"
  20. System SessionMessageRole = "system"
  21. User SessionMessageRole = "user"
  22. )
  23. // ProviderInfo defines model for Provider.Info.
  24. type ProviderInfo struct {
  25. Models map[string]struct {
  26. Attachment bool `json:"attachment"`
  27. ContextWindow float32 `json:"contextWindow"`
  28. Cost struct {
  29. Input float32 `json:"input"`
  30. InputCached float32 `json:"inputCached"`
  31. Output float32 `json:"output"`
  32. OutputCached float32 `json:"outputCached"`
  33. } `json:"cost"`
  34. MaxTokens *float32 `json:"maxTokens,omitempty"`
  35. Name *string `json:"name,omitempty"`
  36. Reasoning *bool `json:"reasoning,omitempty"`
  37. } `json:"models"`
  38. Options *map[string]interface{} `json:"options,omitempty"`
  39. }
  40. // SessionInfo defines model for Session.Info.
  41. type SessionInfo struct {
  42. Id string `json:"id"`
  43. ShareID *string `json:"shareID,omitempty"`
  44. Title string `json:"title"`
  45. }
  46. // SessionMessage defines model for Session.Message.
  47. type SessionMessage struct {
  48. Id string `json:"id"`
  49. Metadata struct {
  50. SessionID string `json:"sessionID"`
  51. Time struct {
  52. Completed *float32 `json:"completed,omitempty"`
  53. Created float32 `json:"created"`
  54. } `json:"time"`
  55. Tool map[string]interface{} `json:"tool"`
  56. } `json:"metadata"`
  57. Parts []SessionMessagePart `json:"parts"`
  58. Role SessionMessageRole `json:"role"`
  59. }
  60. // SessionMessageRole defines model for SessionMessage.Role.
  61. type SessionMessageRole string
  62. // SessionMessagePart defines model for Session.Message.Part.
  63. type SessionMessagePart struct {
  64. union json.RawMessage
  65. }
  66. // SessionMessagePartFile defines model for Session.Message.Part.File.
  67. type SessionMessagePartFile struct {
  68. Filename *string `json:"filename,omitempty"`
  69. MediaType string `json:"mediaType"`
  70. Type string `json:"type"`
  71. Url string `json:"url"`
  72. }
  73. // SessionMessagePartReasoning defines model for Session.Message.Part.Reasoning.
  74. type SessionMessagePartReasoning struct {
  75. ProviderMetadata *map[string]interface{} `json:"providerMetadata,omitempty"`
  76. Text string `json:"text"`
  77. Type string `json:"type"`
  78. }
  79. // SessionMessagePartSourceUrl defines model for Session.Message.Part.SourceUrl.
  80. type SessionMessagePartSourceUrl struct {
  81. ProviderMetadata *map[string]interface{} `json:"providerMetadata,omitempty"`
  82. SourceId string `json:"sourceId"`
  83. Title *string `json:"title,omitempty"`
  84. Type string `json:"type"`
  85. Url string `json:"url"`
  86. }
  87. // SessionMessagePartStepStart defines model for Session.Message.Part.StepStart.
  88. type SessionMessagePartStepStart struct {
  89. Type string `json:"type"`
  90. }
  91. // SessionMessagePartText defines model for Session.Message.Part.Text.
  92. type SessionMessagePartText struct {
  93. Text string `json:"text"`
  94. Type string `json:"type"`
  95. }
  96. // SessionMessagePartToolInvocation defines model for Session.Message.Part.ToolInvocation.
  97. type SessionMessagePartToolInvocation struct {
  98. ToolInvocation SessionMessageToolInvocation `json:"toolInvocation"`
  99. Type string `json:"type"`
  100. }
  101. // SessionMessageToolInvocation defines model for Session.Message.ToolInvocation.
  102. type SessionMessageToolInvocation struct {
  103. union json.RawMessage
  104. }
  105. // SessionMessageToolInvocationToolCall defines model for Session.Message.ToolInvocation.ToolCall.
  106. type SessionMessageToolInvocationToolCall struct {
  107. Args map[string]interface{} `json:"args"`
  108. State string `json:"state"`
  109. Step *float32 `json:"step,omitempty"`
  110. ToolCallId string `json:"toolCallId"`
  111. ToolName string `json:"toolName"`
  112. }
  113. // SessionMessageToolInvocationToolPartialCall defines model for Session.Message.ToolInvocation.ToolPartialCall.
  114. type SessionMessageToolInvocationToolPartialCall struct {
  115. Args map[string]interface{} `json:"args"`
  116. State string `json:"state"`
  117. Step *float32 `json:"step,omitempty"`
  118. ToolCallId string `json:"toolCallId"`
  119. ToolName string `json:"toolName"`
  120. }
  121. // SessionMessageToolInvocationToolResult defines model for Session.Message.ToolInvocation.ToolResult.
  122. type SessionMessageToolInvocationToolResult struct {
  123. Args map[string]interface{} `json:"args"`
  124. Result string `json:"result"`
  125. State string `json:"state"`
  126. Step *float32 `json:"step,omitempty"`
  127. ToolCallId string `json:"toolCallId"`
  128. ToolName string `json:"toolName"`
  129. }
  130. // PostSessionAbortJSONBody defines parameters for PostSessionAbort.
  131. type PostSessionAbortJSONBody struct {
  132. SessionID string `json:"sessionID"`
  133. }
  134. // PostSessionChatJSONBody defines parameters for PostSessionChat.
  135. type PostSessionChatJSONBody struct {
  136. ModelID string `json:"modelID"`
  137. Parts []SessionMessagePart `json:"parts"`
  138. ProviderID string `json:"providerID"`
  139. SessionID string `json:"sessionID"`
  140. }
  141. // PostSessionMessagesJSONBody defines parameters for PostSessionMessages.
  142. type PostSessionMessagesJSONBody struct {
  143. SessionID string `json:"sessionID"`
  144. }
  145. // PostSessionShareJSONBody defines parameters for PostSessionShare.
  146. type PostSessionShareJSONBody struct {
  147. SessionID string `json:"sessionID"`
  148. }
  149. // PostSessionAbortJSONRequestBody defines body for PostSessionAbort for application/json ContentType.
  150. type PostSessionAbortJSONRequestBody PostSessionAbortJSONBody
  151. // PostSessionChatJSONRequestBody defines body for PostSessionChat for application/json ContentType.
  152. type PostSessionChatJSONRequestBody PostSessionChatJSONBody
  153. // PostSessionMessagesJSONRequestBody defines body for PostSessionMessages for application/json ContentType.
  154. type PostSessionMessagesJSONRequestBody PostSessionMessagesJSONBody
  155. // PostSessionShareJSONRequestBody defines body for PostSessionShare for application/json ContentType.
  156. type PostSessionShareJSONRequestBody PostSessionShareJSONBody
  157. // AsSessionMessagePartText returns the union data inside the SessionMessagePart as a SessionMessagePartText
  158. func (t SessionMessagePart) AsSessionMessagePartText() (SessionMessagePartText, error) {
  159. var body SessionMessagePartText
  160. err := json.Unmarshal(t.union, &body)
  161. return body, err
  162. }
  163. // FromSessionMessagePartText overwrites any union data inside the SessionMessagePart as the provided SessionMessagePartText
  164. func (t *SessionMessagePart) FromSessionMessagePartText(v SessionMessagePartText) error {
  165. v.Type = "text"
  166. b, err := json.Marshal(v)
  167. t.union = b
  168. return err
  169. }
  170. // MergeSessionMessagePartText performs a merge with any union data inside the SessionMessagePart, using the provided SessionMessagePartText
  171. func (t *SessionMessagePart) MergeSessionMessagePartText(v SessionMessagePartText) error {
  172. v.Type = "text"
  173. b, err := json.Marshal(v)
  174. if err != nil {
  175. return err
  176. }
  177. merged, err := runtime.JSONMerge(t.union, b)
  178. t.union = merged
  179. return err
  180. }
  181. // AsSessionMessagePartReasoning returns the union data inside the SessionMessagePart as a SessionMessagePartReasoning
  182. func (t SessionMessagePart) AsSessionMessagePartReasoning() (SessionMessagePartReasoning, error) {
  183. var body SessionMessagePartReasoning
  184. err := json.Unmarshal(t.union, &body)
  185. return body, err
  186. }
  187. // FromSessionMessagePartReasoning overwrites any union data inside the SessionMessagePart as the provided SessionMessagePartReasoning
  188. func (t *SessionMessagePart) FromSessionMessagePartReasoning(v SessionMessagePartReasoning) error {
  189. v.Type = "reasoning"
  190. b, err := json.Marshal(v)
  191. t.union = b
  192. return err
  193. }
  194. // MergeSessionMessagePartReasoning performs a merge with any union data inside the SessionMessagePart, using the provided SessionMessagePartReasoning
  195. func (t *SessionMessagePart) MergeSessionMessagePartReasoning(v SessionMessagePartReasoning) error {
  196. v.Type = "reasoning"
  197. b, err := json.Marshal(v)
  198. if err != nil {
  199. return err
  200. }
  201. merged, err := runtime.JSONMerge(t.union, b)
  202. t.union = merged
  203. return err
  204. }
  205. // AsSessionMessagePartToolInvocation returns the union data inside the SessionMessagePart as a SessionMessagePartToolInvocation
  206. func (t SessionMessagePart) AsSessionMessagePartToolInvocation() (SessionMessagePartToolInvocation, error) {
  207. var body SessionMessagePartToolInvocation
  208. err := json.Unmarshal(t.union, &body)
  209. return body, err
  210. }
  211. // FromSessionMessagePartToolInvocation overwrites any union data inside the SessionMessagePart as the provided SessionMessagePartToolInvocation
  212. func (t *SessionMessagePart) FromSessionMessagePartToolInvocation(v SessionMessagePartToolInvocation) error {
  213. v.Type = "tool-invocation"
  214. b, err := json.Marshal(v)
  215. t.union = b
  216. return err
  217. }
  218. // MergeSessionMessagePartToolInvocation performs a merge with any union data inside the SessionMessagePart, using the provided SessionMessagePartToolInvocation
  219. func (t *SessionMessagePart) MergeSessionMessagePartToolInvocation(v SessionMessagePartToolInvocation) error {
  220. v.Type = "tool-invocation"
  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. // AsSessionMessagePartSourceUrl returns the union data inside the SessionMessagePart as a SessionMessagePartSourceUrl
  230. func (t SessionMessagePart) AsSessionMessagePartSourceUrl() (SessionMessagePartSourceUrl, error) {
  231. var body SessionMessagePartSourceUrl
  232. err := json.Unmarshal(t.union, &body)
  233. return body, err
  234. }
  235. // FromSessionMessagePartSourceUrl overwrites any union data inside the SessionMessagePart as the provided SessionMessagePartSourceUrl
  236. func (t *SessionMessagePart) FromSessionMessagePartSourceUrl(v SessionMessagePartSourceUrl) error {
  237. v.Type = "source-url"
  238. b, err := json.Marshal(v)
  239. t.union = b
  240. return err
  241. }
  242. // MergeSessionMessagePartSourceUrl performs a merge with any union data inside the SessionMessagePart, using the provided SessionMessagePartSourceUrl
  243. func (t *SessionMessagePart) MergeSessionMessagePartSourceUrl(v SessionMessagePartSourceUrl) error {
  244. v.Type = "source-url"
  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. // AsSessionMessagePartFile returns the union data inside the SessionMessagePart as a SessionMessagePartFile
  254. func (t SessionMessagePart) AsSessionMessagePartFile() (SessionMessagePartFile, error) {
  255. var body SessionMessagePartFile
  256. err := json.Unmarshal(t.union, &body)
  257. return body, err
  258. }
  259. // FromSessionMessagePartFile overwrites any union data inside the SessionMessagePart as the provided SessionMessagePartFile
  260. func (t *SessionMessagePart) FromSessionMessagePartFile(v SessionMessagePartFile) error {
  261. v.Type = "file"
  262. b, err := json.Marshal(v)
  263. t.union = b
  264. return err
  265. }
  266. // MergeSessionMessagePartFile performs a merge with any union data inside the SessionMessagePart, using the provided SessionMessagePartFile
  267. func (t *SessionMessagePart) MergeSessionMessagePartFile(v SessionMessagePartFile) error {
  268. v.Type = "file"
  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. // AsSessionMessagePartStepStart returns the union data inside the SessionMessagePart as a SessionMessagePartStepStart
  278. func (t SessionMessagePart) AsSessionMessagePartStepStart() (SessionMessagePartStepStart, error) {
  279. var body SessionMessagePartStepStart
  280. err := json.Unmarshal(t.union, &body)
  281. return body, err
  282. }
  283. // FromSessionMessagePartStepStart overwrites any union data inside the SessionMessagePart as the provided SessionMessagePartStepStart
  284. func (t *SessionMessagePart) FromSessionMessagePartStepStart(v SessionMessagePartStepStart) error {
  285. v.Type = "step-start"
  286. b, err := json.Marshal(v)
  287. t.union = b
  288. return err
  289. }
  290. // MergeSessionMessagePartStepStart performs a merge with any union data inside the SessionMessagePart, using the provided SessionMessagePartStepStart
  291. func (t *SessionMessagePart) MergeSessionMessagePartStepStart(v SessionMessagePartStepStart) error {
  292. v.Type = "step-start"
  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 SessionMessagePart) 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 SessionMessagePart) ValueByDiscriminator() (interface{}, error) {
  309. discriminator, err := t.Discriminator()
  310. if err != nil {
  311. return nil, err
  312. }
  313. switch discriminator {
  314. case "file":
  315. return t.AsSessionMessagePartFile()
  316. case "reasoning":
  317. return t.AsSessionMessagePartReasoning()
  318. case "source-url":
  319. return t.AsSessionMessagePartSourceUrl()
  320. case "step-start":
  321. return t.AsSessionMessagePartStepStart()
  322. case "text":
  323. return t.AsSessionMessagePartText()
  324. case "tool-invocation":
  325. return t.AsSessionMessagePartToolInvocation()
  326. default:
  327. return nil, errors.New("unknown discriminator value: " + discriminator)
  328. }
  329. }
  330. func (t SessionMessagePart) MarshalJSON() ([]byte, error) {
  331. b, err := t.union.MarshalJSON()
  332. return b, err
  333. }
  334. func (t *SessionMessagePart) UnmarshalJSON(b []byte) error {
  335. err := t.union.UnmarshalJSON(b)
  336. return err
  337. }
  338. // AsSessionMessageToolInvocationToolCall returns the union data inside the SessionMessageToolInvocation as a SessionMessageToolInvocationToolCall
  339. func (t SessionMessageToolInvocation) AsSessionMessageToolInvocationToolCall() (SessionMessageToolInvocationToolCall, error) {
  340. var body SessionMessageToolInvocationToolCall
  341. err := json.Unmarshal(t.union, &body)
  342. return body, err
  343. }
  344. // FromSessionMessageToolInvocationToolCall overwrites any union data inside the SessionMessageToolInvocation as the provided SessionMessageToolInvocationToolCall
  345. func (t *SessionMessageToolInvocation) FromSessionMessageToolInvocationToolCall(v SessionMessageToolInvocationToolCall) error {
  346. v.State = "call"
  347. b, err := json.Marshal(v)
  348. t.union = b
  349. return err
  350. }
  351. // MergeSessionMessageToolInvocationToolCall performs a merge with any union data inside the SessionMessageToolInvocation, using the provided SessionMessageToolInvocationToolCall
  352. func (t *SessionMessageToolInvocation) MergeSessionMessageToolInvocationToolCall(v SessionMessageToolInvocationToolCall) error {
  353. v.State = "call"
  354. b, err := json.Marshal(v)
  355. if err != nil {
  356. return err
  357. }
  358. merged, err := runtime.JSONMerge(t.union, b)
  359. t.union = merged
  360. return err
  361. }
  362. // AsSessionMessageToolInvocationToolPartialCall returns the union data inside the SessionMessageToolInvocation as a SessionMessageToolInvocationToolPartialCall
  363. func (t SessionMessageToolInvocation) AsSessionMessageToolInvocationToolPartialCall() (SessionMessageToolInvocationToolPartialCall, error) {
  364. var body SessionMessageToolInvocationToolPartialCall
  365. err := json.Unmarshal(t.union, &body)
  366. return body, err
  367. }
  368. // FromSessionMessageToolInvocationToolPartialCall overwrites any union data inside the SessionMessageToolInvocation as the provided SessionMessageToolInvocationToolPartialCall
  369. func (t *SessionMessageToolInvocation) FromSessionMessageToolInvocationToolPartialCall(v SessionMessageToolInvocationToolPartialCall) error {
  370. v.State = "partial-call"
  371. b, err := json.Marshal(v)
  372. t.union = b
  373. return err
  374. }
  375. // MergeSessionMessageToolInvocationToolPartialCall performs a merge with any union data inside the SessionMessageToolInvocation, using the provided SessionMessageToolInvocationToolPartialCall
  376. func (t *SessionMessageToolInvocation) MergeSessionMessageToolInvocationToolPartialCall(v SessionMessageToolInvocationToolPartialCall) error {
  377. v.State = "partial-call"
  378. b, err := json.Marshal(v)
  379. if err != nil {
  380. return err
  381. }
  382. merged, err := runtime.JSONMerge(t.union, b)
  383. t.union = merged
  384. return err
  385. }
  386. // AsSessionMessageToolInvocationToolResult returns the union data inside the SessionMessageToolInvocation as a SessionMessageToolInvocationToolResult
  387. func (t SessionMessageToolInvocation) AsSessionMessageToolInvocationToolResult() (SessionMessageToolInvocationToolResult, error) {
  388. var body SessionMessageToolInvocationToolResult
  389. err := json.Unmarshal(t.union, &body)
  390. return body, err
  391. }
  392. // FromSessionMessageToolInvocationToolResult overwrites any union data inside the SessionMessageToolInvocation as the provided SessionMessageToolInvocationToolResult
  393. func (t *SessionMessageToolInvocation) FromSessionMessageToolInvocationToolResult(v SessionMessageToolInvocationToolResult) error {
  394. v.State = "result"
  395. b, err := json.Marshal(v)
  396. t.union = b
  397. return err
  398. }
  399. // MergeSessionMessageToolInvocationToolResult performs a merge with any union data inside the SessionMessageToolInvocation, using the provided SessionMessageToolInvocationToolResult
  400. func (t *SessionMessageToolInvocation) MergeSessionMessageToolInvocationToolResult(v SessionMessageToolInvocationToolResult) error {
  401. v.State = "result"
  402. b, err := json.Marshal(v)
  403. if err != nil {
  404. return err
  405. }
  406. merged, err := runtime.JSONMerge(t.union, b)
  407. t.union = merged
  408. return err
  409. }
  410. func (t SessionMessageToolInvocation) Discriminator() (string, error) {
  411. var discriminator struct {
  412. Discriminator string `json:"state"`
  413. }
  414. err := json.Unmarshal(t.union, &discriminator)
  415. return discriminator.Discriminator, err
  416. }
  417. func (t SessionMessageToolInvocation) ValueByDiscriminator() (interface{}, error) {
  418. discriminator, err := t.Discriminator()
  419. if err != nil {
  420. return nil, err
  421. }
  422. switch discriminator {
  423. case "call":
  424. return t.AsSessionMessageToolInvocationToolCall()
  425. case "partial-call":
  426. return t.AsSessionMessageToolInvocationToolPartialCall()
  427. case "result":
  428. return t.AsSessionMessageToolInvocationToolResult()
  429. default:
  430. return nil, errors.New("unknown discriminator value: " + discriminator)
  431. }
  432. }
  433. func (t SessionMessageToolInvocation) MarshalJSON() ([]byte, error) {
  434. b, err := t.union.MarshalJSON()
  435. return b, err
  436. }
  437. func (t *SessionMessageToolInvocation) UnmarshalJSON(b []byte) error {
  438. err := t.union.UnmarshalJSON(b)
  439. return err
  440. }
  441. // RequestEditorFn is the function signature for the RequestEditor callback function
  442. type RequestEditorFn func(ctx context.Context, req *http.Request) error
  443. // Doer performs HTTP requests.
  444. //
  445. // The standard http.Client implements this interface.
  446. type HttpRequestDoer interface {
  447. Do(req *http.Request) (*http.Response, error)
  448. }
  449. // Client which conforms to the OpenAPI3 specification for this service.
  450. type Client struct {
  451. // The endpoint of the server conforming to this interface, with scheme,
  452. // https://api.deepmap.com for example. This can contain a path relative
  453. // to the server, such as https://api.deepmap.com/dev-test, and all the
  454. // paths in the swagger spec will be appended to the server.
  455. Server string
  456. // Doer for performing requests, typically a *http.Client with any
  457. // customized settings, such as certificate chains.
  458. Client HttpRequestDoer
  459. // A list of callbacks for modifying requests which are generated before sending over
  460. // the network.
  461. RequestEditors []RequestEditorFn
  462. }
  463. // ClientOption allows setting custom parameters during construction
  464. type ClientOption func(*Client) error
  465. // Creates a new Client, with reasonable defaults
  466. func NewClient(server string, opts ...ClientOption) (*Client, error) {
  467. // create a client with sane default values
  468. client := Client{
  469. Server: server,
  470. }
  471. // mutate client and add all optional params
  472. for _, o := range opts {
  473. if err := o(&client); err != nil {
  474. return nil, err
  475. }
  476. }
  477. // ensure the server URL always has a trailing slash
  478. if !strings.HasSuffix(client.Server, "/") {
  479. client.Server += "/"
  480. }
  481. // create httpClient, if not already present
  482. if client.Client == nil {
  483. client.Client = &http.Client{}
  484. }
  485. return &client, nil
  486. }
  487. // WithHTTPClient allows overriding the default Doer, which is
  488. // automatically created using http.Client. This is useful for tests.
  489. func WithHTTPClient(doer HttpRequestDoer) ClientOption {
  490. return func(c *Client) error {
  491. c.Client = doer
  492. return nil
  493. }
  494. }
  495. // WithRequestEditorFn allows setting up a callback function, which will be
  496. // called right before sending the request. This can be used to mutate the request.
  497. func WithRequestEditorFn(fn RequestEditorFn) ClientOption {
  498. return func(c *Client) error {
  499. c.RequestEditors = append(c.RequestEditors, fn)
  500. return nil
  501. }
  502. }
  503. // The interface specification for the client above.
  504. type ClientInterface interface {
  505. // PostProviderList request
  506. PostProviderList(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error)
  507. // PostSessionAbortWithBody request with any body
  508. PostSessionAbortWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error)
  509. PostSessionAbort(ctx context.Context, body PostSessionAbortJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error)
  510. // PostSessionChatWithBody request with any body
  511. PostSessionChatWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error)
  512. PostSessionChat(ctx context.Context, body PostSessionChatJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error)
  513. // PostSessionCreate request
  514. PostSessionCreate(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error)
  515. // PostSessionList request
  516. PostSessionList(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error)
  517. // PostSessionMessagesWithBody request with any body
  518. PostSessionMessagesWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error)
  519. PostSessionMessages(ctx context.Context, body PostSessionMessagesJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error)
  520. // PostSessionShareWithBody request with any body
  521. PostSessionShareWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error)
  522. PostSessionShare(ctx context.Context, body PostSessionShareJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error)
  523. }
  524. func (c *Client) PostProviderList(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error) {
  525. req, err := NewPostProviderListRequest(c.Server)
  526. if err != nil {
  527. return nil, err
  528. }
  529. req = req.WithContext(ctx)
  530. if err := c.applyEditors(ctx, req, reqEditors); err != nil {
  531. return nil, err
  532. }
  533. return c.Client.Do(req)
  534. }
  535. func (c *Client) PostSessionAbortWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) {
  536. req, err := NewPostSessionAbortRequestWithBody(c.Server, contentType, body)
  537. if err != nil {
  538. return nil, err
  539. }
  540. req = req.WithContext(ctx)
  541. if err := c.applyEditors(ctx, req, reqEditors); err != nil {
  542. return nil, err
  543. }
  544. return c.Client.Do(req)
  545. }
  546. func (c *Client) PostSessionAbort(ctx context.Context, body PostSessionAbortJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) {
  547. req, err := NewPostSessionAbortRequest(c.Server, body)
  548. if err != nil {
  549. return nil, err
  550. }
  551. req = req.WithContext(ctx)
  552. if err := c.applyEditors(ctx, req, reqEditors); err != nil {
  553. return nil, err
  554. }
  555. return c.Client.Do(req)
  556. }
  557. func (c *Client) PostSessionChatWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) {
  558. req, err := NewPostSessionChatRequestWithBody(c.Server, contentType, body)
  559. if err != nil {
  560. return nil, err
  561. }
  562. req = req.WithContext(ctx)
  563. if err := c.applyEditors(ctx, req, reqEditors); err != nil {
  564. return nil, err
  565. }
  566. return c.Client.Do(req)
  567. }
  568. func (c *Client) PostSessionChat(ctx context.Context, body PostSessionChatJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) {
  569. req, err := NewPostSessionChatRequest(c.Server, body)
  570. if err != nil {
  571. return nil, err
  572. }
  573. req = req.WithContext(ctx)
  574. if err := c.applyEditors(ctx, req, reqEditors); err != nil {
  575. return nil, err
  576. }
  577. return c.Client.Do(req)
  578. }
  579. func (c *Client) PostSessionCreate(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error) {
  580. req, err := NewPostSessionCreateRequest(c.Server)
  581. if err != nil {
  582. return nil, err
  583. }
  584. req = req.WithContext(ctx)
  585. if err := c.applyEditors(ctx, req, reqEditors); err != nil {
  586. return nil, err
  587. }
  588. return c.Client.Do(req)
  589. }
  590. func (c *Client) PostSessionList(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error) {
  591. req, err := NewPostSessionListRequest(c.Server)
  592. if err != nil {
  593. return nil, err
  594. }
  595. req = req.WithContext(ctx)
  596. if err := c.applyEditors(ctx, req, reqEditors); err != nil {
  597. return nil, err
  598. }
  599. return c.Client.Do(req)
  600. }
  601. func (c *Client) PostSessionMessagesWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) {
  602. req, err := NewPostSessionMessagesRequestWithBody(c.Server, contentType, body)
  603. if err != nil {
  604. return nil, err
  605. }
  606. req = req.WithContext(ctx)
  607. if err := c.applyEditors(ctx, req, reqEditors); err != nil {
  608. return nil, err
  609. }
  610. return c.Client.Do(req)
  611. }
  612. func (c *Client) PostSessionMessages(ctx context.Context, body PostSessionMessagesJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) {
  613. req, err := NewPostSessionMessagesRequest(c.Server, body)
  614. if err != nil {
  615. return nil, err
  616. }
  617. req = req.WithContext(ctx)
  618. if err := c.applyEditors(ctx, req, reqEditors); err != nil {
  619. return nil, err
  620. }
  621. return c.Client.Do(req)
  622. }
  623. func (c *Client) PostSessionShareWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) {
  624. req, err := NewPostSessionShareRequestWithBody(c.Server, contentType, body)
  625. if err != nil {
  626. return nil, err
  627. }
  628. req = req.WithContext(ctx)
  629. if err := c.applyEditors(ctx, req, reqEditors); err != nil {
  630. return nil, err
  631. }
  632. return c.Client.Do(req)
  633. }
  634. func (c *Client) PostSessionShare(ctx context.Context, body PostSessionShareJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) {
  635. req, err := NewPostSessionShareRequest(c.Server, body)
  636. if err != nil {
  637. return nil, err
  638. }
  639. req = req.WithContext(ctx)
  640. if err := c.applyEditors(ctx, req, reqEditors); err != nil {
  641. return nil, err
  642. }
  643. return c.Client.Do(req)
  644. }
  645. // NewPostProviderListRequest generates requests for PostProviderList
  646. func NewPostProviderListRequest(server string) (*http.Request, error) {
  647. var err error
  648. serverURL, err := url.Parse(server)
  649. if err != nil {
  650. return nil, err
  651. }
  652. operationPath := fmt.Sprintf("/provider_list")
  653. if operationPath[0] == '/' {
  654. operationPath = "." + operationPath
  655. }
  656. queryURL, err := serverURL.Parse(operationPath)
  657. if err != nil {
  658. return nil, err
  659. }
  660. req, err := http.NewRequest("POST", queryURL.String(), nil)
  661. if err != nil {
  662. return nil, err
  663. }
  664. return req, nil
  665. }
  666. // NewPostSessionAbortRequest calls the generic PostSessionAbort builder with application/json body
  667. func NewPostSessionAbortRequest(server string, body PostSessionAbortJSONRequestBody) (*http.Request, error) {
  668. var bodyReader io.Reader
  669. buf, err := json.Marshal(body)
  670. if err != nil {
  671. return nil, err
  672. }
  673. bodyReader = bytes.NewReader(buf)
  674. return NewPostSessionAbortRequestWithBody(server, "application/json", bodyReader)
  675. }
  676. // NewPostSessionAbortRequestWithBody generates requests for PostSessionAbort with any type of body
  677. func NewPostSessionAbortRequestWithBody(server string, contentType string, body io.Reader) (*http.Request, error) {
  678. var err error
  679. serverURL, err := url.Parse(server)
  680. if err != nil {
  681. return nil, err
  682. }
  683. operationPath := fmt.Sprintf("/session_abort")
  684. if operationPath[0] == '/' {
  685. operationPath = "." + operationPath
  686. }
  687. queryURL, err := serverURL.Parse(operationPath)
  688. if err != nil {
  689. return nil, err
  690. }
  691. req, err := http.NewRequest("POST", queryURL.String(), body)
  692. if err != nil {
  693. return nil, err
  694. }
  695. req.Header.Add("Content-Type", contentType)
  696. return req, nil
  697. }
  698. // NewPostSessionChatRequest calls the generic PostSessionChat builder with application/json body
  699. func NewPostSessionChatRequest(server string, body PostSessionChatJSONRequestBody) (*http.Request, error) {
  700. var bodyReader io.Reader
  701. buf, err := json.Marshal(body)
  702. if err != nil {
  703. return nil, err
  704. }
  705. bodyReader = bytes.NewReader(buf)
  706. return NewPostSessionChatRequestWithBody(server, "application/json", bodyReader)
  707. }
  708. // NewPostSessionChatRequestWithBody generates requests for PostSessionChat with any type of body
  709. func NewPostSessionChatRequestWithBody(server string, contentType string, body io.Reader) (*http.Request, error) {
  710. var err error
  711. serverURL, err := url.Parse(server)
  712. if err != nil {
  713. return nil, err
  714. }
  715. operationPath := fmt.Sprintf("/session_chat")
  716. if operationPath[0] == '/' {
  717. operationPath = "." + operationPath
  718. }
  719. queryURL, err := serverURL.Parse(operationPath)
  720. if err != nil {
  721. return nil, err
  722. }
  723. req, err := http.NewRequest("POST", queryURL.String(), body)
  724. if err != nil {
  725. return nil, err
  726. }
  727. req.Header.Add("Content-Type", contentType)
  728. return req, nil
  729. }
  730. // NewPostSessionCreateRequest generates requests for PostSessionCreate
  731. func NewPostSessionCreateRequest(server string) (*http.Request, error) {
  732. var err error
  733. serverURL, err := url.Parse(server)
  734. if err != nil {
  735. return nil, err
  736. }
  737. operationPath := fmt.Sprintf("/session_create")
  738. if operationPath[0] == '/' {
  739. operationPath = "." + operationPath
  740. }
  741. queryURL, err := serverURL.Parse(operationPath)
  742. if err != nil {
  743. return nil, err
  744. }
  745. req, err := http.NewRequest("POST", queryURL.String(), nil)
  746. if err != nil {
  747. return nil, err
  748. }
  749. return req, nil
  750. }
  751. // NewPostSessionListRequest generates requests for PostSessionList
  752. func NewPostSessionListRequest(server string) (*http.Request, error) {
  753. var err error
  754. serverURL, err := url.Parse(server)
  755. if err != nil {
  756. return nil, err
  757. }
  758. operationPath := fmt.Sprintf("/session_list")
  759. if operationPath[0] == '/' {
  760. operationPath = "." + operationPath
  761. }
  762. queryURL, err := serverURL.Parse(operationPath)
  763. if err != nil {
  764. return nil, err
  765. }
  766. req, err := http.NewRequest("POST", queryURL.String(), nil)
  767. if err != nil {
  768. return nil, err
  769. }
  770. return req, nil
  771. }
  772. // NewPostSessionMessagesRequest calls the generic PostSessionMessages builder with application/json body
  773. func NewPostSessionMessagesRequest(server string, body PostSessionMessagesJSONRequestBody) (*http.Request, error) {
  774. var bodyReader io.Reader
  775. buf, err := json.Marshal(body)
  776. if err != nil {
  777. return nil, err
  778. }
  779. bodyReader = bytes.NewReader(buf)
  780. return NewPostSessionMessagesRequestWithBody(server, "application/json", bodyReader)
  781. }
  782. // NewPostSessionMessagesRequestWithBody generates requests for PostSessionMessages with any type of body
  783. func NewPostSessionMessagesRequestWithBody(server string, contentType string, body io.Reader) (*http.Request, error) {
  784. var err error
  785. serverURL, err := url.Parse(server)
  786. if err != nil {
  787. return nil, err
  788. }
  789. operationPath := fmt.Sprintf("/session_messages")
  790. if operationPath[0] == '/' {
  791. operationPath = "." + operationPath
  792. }
  793. queryURL, err := serverURL.Parse(operationPath)
  794. if err != nil {
  795. return nil, err
  796. }
  797. req, err := http.NewRequest("POST", queryURL.String(), body)
  798. if err != nil {
  799. return nil, err
  800. }
  801. req.Header.Add("Content-Type", contentType)
  802. return req, nil
  803. }
  804. // NewPostSessionShareRequest calls the generic PostSessionShare builder with application/json body
  805. func NewPostSessionShareRequest(server string, body PostSessionShareJSONRequestBody) (*http.Request, error) {
  806. var bodyReader io.Reader
  807. buf, err := json.Marshal(body)
  808. if err != nil {
  809. return nil, err
  810. }
  811. bodyReader = bytes.NewReader(buf)
  812. return NewPostSessionShareRequestWithBody(server, "application/json", bodyReader)
  813. }
  814. // NewPostSessionShareRequestWithBody generates requests for PostSessionShare with any type of body
  815. func NewPostSessionShareRequestWithBody(server string, contentType string, body io.Reader) (*http.Request, error) {
  816. var err error
  817. serverURL, err := url.Parse(server)
  818. if err != nil {
  819. return nil, err
  820. }
  821. operationPath := fmt.Sprintf("/session_share")
  822. if operationPath[0] == '/' {
  823. operationPath = "." + operationPath
  824. }
  825. queryURL, err := serverURL.Parse(operationPath)
  826. if err != nil {
  827. return nil, err
  828. }
  829. req, err := http.NewRequest("POST", queryURL.String(), body)
  830. if err != nil {
  831. return nil, err
  832. }
  833. req.Header.Add("Content-Type", contentType)
  834. return req, nil
  835. }
  836. func (c *Client) applyEditors(ctx context.Context, req *http.Request, additionalEditors []RequestEditorFn) error {
  837. for _, r := range c.RequestEditors {
  838. if err := r(ctx, req); err != nil {
  839. return err
  840. }
  841. }
  842. for _, r := range additionalEditors {
  843. if err := r(ctx, req); err != nil {
  844. return err
  845. }
  846. }
  847. return nil
  848. }
  849. // ClientWithResponses builds on ClientInterface to offer response payloads
  850. type ClientWithResponses struct {
  851. ClientInterface
  852. }
  853. // NewClientWithResponses creates a new ClientWithResponses, which wraps
  854. // Client with return type handling
  855. func NewClientWithResponses(server string, opts ...ClientOption) (*ClientWithResponses, error) {
  856. client, err := NewClient(server, opts...)
  857. if err != nil {
  858. return nil, err
  859. }
  860. return &ClientWithResponses{client}, nil
  861. }
  862. // WithBaseURL overrides the baseURL.
  863. func WithBaseURL(baseURL string) ClientOption {
  864. return func(c *Client) error {
  865. newBaseURL, err := url.Parse(baseURL)
  866. if err != nil {
  867. return err
  868. }
  869. c.Server = newBaseURL.String()
  870. return nil
  871. }
  872. }
  873. // ClientWithResponsesInterface is the interface specification for the client with responses above.
  874. type ClientWithResponsesInterface interface {
  875. // PostProviderListWithResponse request
  876. PostProviderListWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*PostProviderListResponse, error)
  877. // PostSessionAbortWithBodyWithResponse request with any body
  878. PostSessionAbortWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*PostSessionAbortResponse, error)
  879. PostSessionAbortWithResponse(ctx context.Context, body PostSessionAbortJSONRequestBody, reqEditors ...RequestEditorFn) (*PostSessionAbortResponse, error)
  880. // PostSessionChatWithBodyWithResponse request with any body
  881. PostSessionChatWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*PostSessionChatResponse, error)
  882. PostSessionChatWithResponse(ctx context.Context, body PostSessionChatJSONRequestBody, reqEditors ...RequestEditorFn) (*PostSessionChatResponse, error)
  883. // PostSessionCreateWithResponse request
  884. PostSessionCreateWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*PostSessionCreateResponse, error)
  885. // PostSessionListWithResponse request
  886. PostSessionListWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*PostSessionListResponse, error)
  887. // PostSessionMessagesWithBodyWithResponse request with any body
  888. PostSessionMessagesWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*PostSessionMessagesResponse, error)
  889. PostSessionMessagesWithResponse(ctx context.Context, body PostSessionMessagesJSONRequestBody, reqEditors ...RequestEditorFn) (*PostSessionMessagesResponse, error)
  890. // PostSessionShareWithBodyWithResponse request with any body
  891. PostSessionShareWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*PostSessionShareResponse, error)
  892. PostSessionShareWithResponse(ctx context.Context, body PostSessionShareJSONRequestBody, reqEditors ...RequestEditorFn) (*PostSessionShareResponse, error)
  893. }
  894. type PostProviderListResponse struct {
  895. Body []byte
  896. HTTPResponse *http.Response
  897. JSON200 *map[string]ProviderInfo
  898. }
  899. // Status returns HTTPResponse.Status
  900. func (r PostProviderListResponse) Status() string {
  901. if r.HTTPResponse != nil {
  902. return r.HTTPResponse.Status
  903. }
  904. return http.StatusText(0)
  905. }
  906. // StatusCode returns HTTPResponse.StatusCode
  907. func (r PostProviderListResponse) StatusCode() int {
  908. if r.HTTPResponse != nil {
  909. return r.HTTPResponse.StatusCode
  910. }
  911. return 0
  912. }
  913. type PostSessionAbortResponse struct {
  914. Body []byte
  915. HTTPResponse *http.Response
  916. JSON200 *bool
  917. }
  918. // Status returns HTTPResponse.Status
  919. func (r PostSessionAbortResponse) Status() string {
  920. if r.HTTPResponse != nil {
  921. return r.HTTPResponse.Status
  922. }
  923. return http.StatusText(0)
  924. }
  925. // StatusCode returns HTTPResponse.StatusCode
  926. func (r PostSessionAbortResponse) StatusCode() int {
  927. if r.HTTPResponse != nil {
  928. return r.HTTPResponse.StatusCode
  929. }
  930. return 0
  931. }
  932. type PostSessionChatResponse struct {
  933. Body []byte
  934. HTTPResponse *http.Response
  935. JSON200 *SessionMessage
  936. }
  937. // Status returns HTTPResponse.Status
  938. func (r PostSessionChatResponse) Status() string {
  939. if r.HTTPResponse != nil {
  940. return r.HTTPResponse.Status
  941. }
  942. return http.StatusText(0)
  943. }
  944. // StatusCode returns HTTPResponse.StatusCode
  945. func (r PostSessionChatResponse) StatusCode() int {
  946. if r.HTTPResponse != nil {
  947. return r.HTTPResponse.StatusCode
  948. }
  949. return 0
  950. }
  951. type PostSessionCreateResponse struct {
  952. Body []byte
  953. HTTPResponse *http.Response
  954. JSON200 *SessionInfo
  955. }
  956. // Status returns HTTPResponse.Status
  957. func (r PostSessionCreateResponse) Status() string {
  958. if r.HTTPResponse != nil {
  959. return r.HTTPResponse.Status
  960. }
  961. return http.StatusText(0)
  962. }
  963. // StatusCode returns HTTPResponse.StatusCode
  964. func (r PostSessionCreateResponse) StatusCode() int {
  965. if r.HTTPResponse != nil {
  966. return r.HTTPResponse.StatusCode
  967. }
  968. return 0
  969. }
  970. type PostSessionListResponse struct {
  971. Body []byte
  972. HTTPResponse *http.Response
  973. JSON200 *[]struct {
  974. Id string `json:"id"`
  975. ShareID *string `json:"shareID,omitempty"`
  976. Title string `json:"title"`
  977. }
  978. }
  979. // Status returns HTTPResponse.Status
  980. func (r PostSessionListResponse) Status() string {
  981. if r.HTTPResponse != nil {
  982. return r.HTTPResponse.Status
  983. }
  984. return http.StatusText(0)
  985. }
  986. // StatusCode returns HTTPResponse.StatusCode
  987. func (r PostSessionListResponse) StatusCode() int {
  988. if r.HTTPResponse != nil {
  989. return r.HTTPResponse.StatusCode
  990. }
  991. return 0
  992. }
  993. type PostSessionMessagesResponse struct {
  994. Body []byte
  995. HTTPResponse *http.Response
  996. JSON200 *[]SessionMessage
  997. }
  998. // Status returns HTTPResponse.Status
  999. func (r PostSessionMessagesResponse) Status() string {
  1000. if r.HTTPResponse != nil {
  1001. return r.HTTPResponse.Status
  1002. }
  1003. return http.StatusText(0)
  1004. }
  1005. // StatusCode returns HTTPResponse.StatusCode
  1006. func (r PostSessionMessagesResponse) StatusCode() int {
  1007. if r.HTTPResponse != nil {
  1008. return r.HTTPResponse.StatusCode
  1009. }
  1010. return 0
  1011. }
  1012. type PostSessionShareResponse struct {
  1013. Body []byte
  1014. HTTPResponse *http.Response
  1015. JSON200 *SessionInfo
  1016. }
  1017. // Status returns HTTPResponse.Status
  1018. func (r PostSessionShareResponse) Status() string {
  1019. if r.HTTPResponse != nil {
  1020. return r.HTTPResponse.Status
  1021. }
  1022. return http.StatusText(0)
  1023. }
  1024. // StatusCode returns HTTPResponse.StatusCode
  1025. func (r PostSessionShareResponse) StatusCode() int {
  1026. if r.HTTPResponse != nil {
  1027. return r.HTTPResponse.StatusCode
  1028. }
  1029. return 0
  1030. }
  1031. // PostProviderListWithResponse request returning *PostProviderListResponse
  1032. func (c *ClientWithResponses) PostProviderListWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*PostProviderListResponse, error) {
  1033. rsp, err := c.PostProviderList(ctx, reqEditors...)
  1034. if err != nil {
  1035. return nil, err
  1036. }
  1037. return ParsePostProviderListResponse(rsp)
  1038. }
  1039. // PostSessionAbortWithBodyWithResponse request with arbitrary body returning *PostSessionAbortResponse
  1040. func (c *ClientWithResponses) PostSessionAbortWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*PostSessionAbortResponse, error) {
  1041. rsp, err := c.PostSessionAbortWithBody(ctx, contentType, body, reqEditors...)
  1042. if err != nil {
  1043. return nil, err
  1044. }
  1045. return ParsePostSessionAbortResponse(rsp)
  1046. }
  1047. func (c *ClientWithResponses) PostSessionAbortWithResponse(ctx context.Context, body PostSessionAbortJSONRequestBody, reqEditors ...RequestEditorFn) (*PostSessionAbortResponse, error) {
  1048. rsp, err := c.PostSessionAbort(ctx, body, reqEditors...)
  1049. if err != nil {
  1050. return nil, err
  1051. }
  1052. return ParsePostSessionAbortResponse(rsp)
  1053. }
  1054. // PostSessionChatWithBodyWithResponse request with arbitrary body returning *PostSessionChatResponse
  1055. func (c *ClientWithResponses) PostSessionChatWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*PostSessionChatResponse, error) {
  1056. rsp, err := c.PostSessionChatWithBody(ctx, contentType, body, reqEditors...)
  1057. if err != nil {
  1058. return nil, err
  1059. }
  1060. return ParsePostSessionChatResponse(rsp)
  1061. }
  1062. func (c *ClientWithResponses) PostSessionChatWithResponse(ctx context.Context, body PostSessionChatJSONRequestBody, reqEditors ...RequestEditorFn) (*PostSessionChatResponse, error) {
  1063. rsp, err := c.PostSessionChat(ctx, body, reqEditors...)
  1064. if err != nil {
  1065. return nil, err
  1066. }
  1067. return ParsePostSessionChatResponse(rsp)
  1068. }
  1069. // PostSessionCreateWithResponse request returning *PostSessionCreateResponse
  1070. func (c *ClientWithResponses) PostSessionCreateWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*PostSessionCreateResponse, error) {
  1071. rsp, err := c.PostSessionCreate(ctx, reqEditors...)
  1072. if err != nil {
  1073. return nil, err
  1074. }
  1075. return ParsePostSessionCreateResponse(rsp)
  1076. }
  1077. // PostSessionListWithResponse request returning *PostSessionListResponse
  1078. func (c *ClientWithResponses) PostSessionListWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*PostSessionListResponse, error) {
  1079. rsp, err := c.PostSessionList(ctx, reqEditors...)
  1080. if err != nil {
  1081. return nil, err
  1082. }
  1083. return ParsePostSessionListResponse(rsp)
  1084. }
  1085. // PostSessionMessagesWithBodyWithResponse request with arbitrary body returning *PostSessionMessagesResponse
  1086. func (c *ClientWithResponses) PostSessionMessagesWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*PostSessionMessagesResponse, error) {
  1087. rsp, err := c.PostSessionMessagesWithBody(ctx, contentType, body, reqEditors...)
  1088. if err != nil {
  1089. return nil, err
  1090. }
  1091. return ParsePostSessionMessagesResponse(rsp)
  1092. }
  1093. func (c *ClientWithResponses) PostSessionMessagesWithResponse(ctx context.Context, body PostSessionMessagesJSONRequestBody, reqEditors ...RequestEditorFn) (*PostSessionMessagesResponse, error) {
  1094. rsp, err := c.PostSessionMessages(ctx, body, reqEditors...)
  1095. if err != nil {
  1096. return nil, err
  1097. }
  1098. return ParsePostSessionMessagesResponse(rsp)
  1099. }
  1100. // PostSessionShareWithBodyWithResponse request with arbitrary body returning *PostSessionShareResponse
  1101. func (c *ClientWithResponses) PostSessionShareWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*PostSessionShareResponse, error) {
  1102. rsp, err := c.PostSessionShareWithBody(ctx, contentType, body, reqEditors...)
  1103. if err != nil {
  1104. return nil, err
  1105. }
  1106. return ParsePostSessionShareResponse(rsp)
  1107. }
  1108. func (c *ClientWithResponses) PostSessionShareWithResponse(ctx context.Context, body PostSessionShareJSONRequestBody, reqEditors ...RequestEditorFn) (*PostSessionShareResponse, error) {
  1109. rsp, err := c.PostSessionShare(ctx, body, reqEditors...)
  1110. if err != nil {
  1111. return nil, err
  1112. }
  1113. return ParsePostSessionShareResponse(rsp)
  1114. }
  1115. // ParsePostProviderListResponse parses an HTTP response from a PostProviderListWithResponse call
  1116. func ParsePostProviderListResponse(rsp *http.Response) (*PostProviderListResponse, error) {
  1117. bodyBytes, err := io.ReadAll(rsp.Body)
  1118. defer func() { _ = rsp.Body.Close() }()
  1119. if err != nil {
  1120. return nil, err
  1121. }
  1122. response := &PostProviderListResponse{
  1123. Body: bodyBytes,
  1124. HTTPResponse: rsp,
  1125. }
  1126. switch {
  1127. case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200:
  1128. var dest map[string]ProviderInfo
  1129. if err := json.Unmarshal(bodyBytes, &dest); err != nil {
  1130. return nil, err
  1131. }
  1132. response.JSON200 = &dest
  1133. }
  1134. return response, nil
  1135. }
  1136. // ParsePostSessionAbortResponse parses an HTTP response from a PostSessionAbortWithResponse call
  1137. func ParsePostSessionAbortResponse(rsp *http.Response) (*PostSessionAbortResponse, error) {
  1138. bodyBytes, err := io.ReadAll(rsp.Body)
  1139. defer func() { _ = rsp.Body.Close() }()
  1140. if err != nil {
  1141. return nil, err
  1142. }
  1143. response := &PostSessionAbortResponse{
  1144. Body: bodyBytes,
  1145. HTTPResponse: rsp,
  1146. }
  1147. switch {
  1148. case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200:
  1149. var dest bool
  1150. if err := json.Unmarshal(bodyBytes, &dest); err != nil {
  1151. return nil, err
  1152. }
  1153. response.JSON200 = &dest
  1154. }
  1155. return response, nil
  1156. }
  1157. // ParsePostSessionChatResponse parses an HTTP response from a PostSessionChatWithResponse call
  1158. func ParsePostSessionChatResponse(rsp *http.Response) (*PostSessionChatResponse, error) {
  1159. bodyBytes, err := io.ReadAll(rsp.Body)
  1160. defer func() { _ = rsp.Body.Close() }()
  1161. if err != nil {
  1162. return nil, err
  1163. }
  1164. response := &PostSessionChatResponse{
  1165. Body: bodyBytes,
  1166. HTTPResponse: rsp,
  1167. }
  1168. switch {
  1169. case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200:
  1170. var dest SessionMessage
  1171. if err := json.Unmarshal(bodyBytes, &dest); err != nil {
  1172. return nil, err
  1173. }
  1174. response.JSON200 = &dest
  1175. }
  1176. return response, nil
  1177. }
  1178. // ParsePostSessionCreateResponse parses an HTTP response from a PostSessionCreateWithResponse call
  1179. func ParsePostSessionCreateResponse(rsp *http.Response) (*PostSessionCreateResponse, error) {
  1180. bodyBytes, err := io.ReadAll(rsp.Body)
  1181. defer func() { _ = rsp.Body.Close() }()
  1182. if err != nil {
  1183. return nil, err
  1184. }
  1185. response := &PostSessionCreateResponse{
  1186. Body: bodyBytes,
  1187. HTTPResponse: rsp,
  1188. }
  1189. switch {
  1190. case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200:
  1191. var dest SessionInfo
  1192. if err := json.Unmarshal(bodyBytes, &dest); err != nil {
  1193. return nil, err
  1194. }
  1195. response.JSON200 = &dest
  1196. }
  1197. return response, nil
  1198. }
  1199. // ParsePostSessionListResponse parses an HTTP response from a PostSessionListWithResponse call
  1200. func ParsePostSessionListResponse(rsp *http.Response) (*PostSessionListResponse, error) {
  1201. bodyBytes, err := io.ReadAll(rsp.Body)
  1202. defer func() { _ = rsp.Body.Close() }()
  1203. if err != nil {
  1204. return nil, err
  1205. }
  1206. response := &PostSessionListResponse{
  1207. Body: bodyBytes,
  1208. HTTPResponse: rsp,
  1209. }
  1210. switch {
  1211. case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200:
  1212. var dest []struct {
  1213. Id string `json:"id"`
  1214. ShareID *string `json:"shareID,omitempty"`
  1215. Title string `json:"title"`
  1216. }
  1217. if err := json.Unmarshal(bodyBytes, &dest); err != nil {
  1218. return nil, err
  1219. }
  1220. response.JSON200 = &dest
  1221. }
  1222. return response, nil
  1223. }
  1224. // ParsePostSessionMessagesResponse parses an HTTP response from a PostSessionMessagesWithResponse call
  1225. func ParsePostSessionMessagesResponse(rsp *http.Response) (*PostSessionMessagesResponse, error) {
  1226. bodyBytes, err := io.ReadAll(rsp.Body)
  1227. defer func() { _ = rsp.Body.Close() }()
  1228. if err != nil {
  1229. return nil, err
  1230. }
  1231. response := &PostSessionMessagesResponse{
  1232. Body: bodyBytes,
  1233. HTTPResponse: rsp,
  1234. }
  1235. switch {
  1236. case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200:
  1237. var dest []SessionMessage
  1238. if err := json.Unmarshal(bodyBytes, &dest); err != nil {
  1239. return nil, err
  1240. }
  1241. response.JSON200 = &dest
  1242. }
  1243. return response, nil
  1244. }
  1245. // ParsePostSessionShareResponse parses an HTTP response from a PostSessionShareWithResponse call
  1246. func ParsePostSessionShareResponse(rsp *http.Response) (*PostSessionShareResponse, error) {
  1247. bodyBytes, err := io.ReadAll(rsp.Body)
  1248. defer func() { _ = rsp.Body.Close() }()
  1249. if err != nil {
  1250. return nil, err
  1251. }
  1252. response := &PostSessionShareResponse{
  1253. Body: bodyBytes,
  1254. HTTPResponse: rsp,
  1255. }
  1256. switch {
  1257. case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200:
  1258. var dest SessionInfo
  1259. if err := json.Unmarshal(bodyBytes, &dest); err != nil {
  1260. return nil, err
  1261. }
  1262. response.JSON200 = &dest
  1263. }
  1264. return response, nil
  1265. }