generated-client.go 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798
  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. "fmt"
  10. "io"
  11. "net/http"
  12. "net/url"
  13. "strings"
  14. )
  15. // SessionInfo defines model for Session.Info.
  16. type SessionInfo struct {
  17. Id string `json:"id"`
  18. ShareID *string `json:"shareID,omitempty"`
  19. Title string `json:"title"`
  20. Tokens struct {
  21. Input float32 `json:"input"`
  22. Output float32 `json:"output"`
  23. Reasoning float32 `json:"reasoning"`
  24. } `json:"tokens"`
  25. }
  26. // PostSessionChatJSONBody defines parameters for PostSessionChat.
  27. type PostSessionChatJSONBody struct {
  28. Parts *interface{} `json:"parts,omitempty"`
  29. SessionID string `json:"sessionID"`
  30. }
  31. // PostSessionMessagesJSONBody defines parameters for PostSessionMessages.
  32. type PostSessionMessagesJSONBody struct {
  33. SessionID string `json:"sessionID"`
  34. }
  35. // PostSessionShareJSONBody defines parameters for PostSessionShare.
  36. type PostSessionShareJSONBody struct {
  37. SessionID string `json:"sessionID"`
  38. }
  39. // PostSessionChatJSONRequestBody defines body for PostSessionChat for application/json ContentType.
  40. type PostSessionChatJSONRequestBody PostSessionChatJSONBody
  41. // PostSessionMessagesJSONRequestBody defines body for PostSessionMessages for application/json ContentType.
  42. type PostSessionMessagesJSONRequestBody PostSessionMessagesJSONBody
  43. // PostSessionShareJSONRequestBody defines body for PostSessionShare for application/json ContentType.
  44. type PostSessionShareJSONRequestBody PostSessionShareJSONBody
  45. // RequestEditorFn is the function signature for the RequestEditor callback function
  46. type RequestEditorFn func(ctx context.Context, req *http.Request) error
  47. // Doer performs HTTP requests.
  48. //
  49. // The standard http.Client implements this interface.
  50. type HttpRequestDoer interface {
  51. Do(req *http.Request) (*http.Response, error)
  52. }
  53. // Client which conforms to the OpenAPI3 specification for this service.
  54. type Client struct {
  55. // The endpoint of the server conforming to this interface, with scheme,
  56. // https://api.deepmap.com for example. This can contain a path relative
  57. // to the server, such as https://api.deepmap.com/dev-test, and all the
  58. // paths in the swagger spec will be appended to the server.
  59. Server string
  60. // Doer for performing requests, typically a *http.Client with any
  61. // customized settings, such as certificate chains.
  62. Client HttpRequestDoer
  63. // A list of callbacks for modifying requests which are generated before sending over
  64. // the network.
  65. RequestEditors []RequestEditorFn
  66. }
  67. // ClientOption allows setting custom parameters during construction
  68. type ClientOption func(*Client) error
  69. // Creates a new Client, with reasonable defaults
  70. func NewClient(server string, opts ...ClientOption) (*Client, error) {
  71. // create a client with sane default values
  72. client := Client{
  73. Server: server,
  74. }
  75. // mutate client and add all optional params
  76. for _, o := range opts {
  77. if err := o(&client); err != nil {
  78. return nil, err
  79. }
  80. }
  81. // ensure the server URL always has a trailing slash
  82. if !strings.HasSuffix(client.Server, "/") {
  83. client.Server += "/"
  84. }
  85. // create httpClient, if not already present
  86. if client.Client == nil {
  87. client.Client = &http.Client{}
  88. }
  89. return &client, nil
  90. }
  91. // WithHTTPClient allows overriding the default Doer, which is
  92. // automatically created using http.Client. This is useful for tests.
  93. func WithHTTPClient(doer HttpRequestDoer) ClientOption {
  94. return func(c *Client) error {
  95. c.Client = doer
  96. return nil
  97. }
  98. }
  99. // WithRequestEditorFn allows setting up a callback function, which will be
  100. // called right before sending the request. This can be used to mutate the request.
  101. func WithRequestEditorFn(fn RequestEditorFn) ClientOption {
  102. return func(c *Client) error {
  103. c.RequestEditors = append(c.RequestEditors, fn)
  104. return nil
  105. }
  106. }
  107. // The interface specification for the client above.
  108. type ClientInterface interface {
  109. // PostSessionChatWithBody request with any body
  110. PostSessionChatWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error)
  111. PostSessionChat(ctx context.Context, body PostSessionChatJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error)
  112. // PostSessionCreate request
  113. PostSessionCreate(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error)
  114. // PostSessionList request
  115. PostSessionList(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error)
  116. // PostSessionMessagesWithBody request with any body
  117. PostSessionMessagesWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error)
  118. PostSessionMessages(ctx context.Context, body PostSessionMessagesJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error)
  119. // PostSessionShareWithBody request with any body
  120. PostSessionShareWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error)
  121. PostSessionShare(ctx context.Context, body PostSessionShareJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error)
  122. }
  123. func (c *Client) PostSessionChatWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) {
  124. req, err := NewPostSessionChatRequestWithBody(c.Server, contentType, body)
  125. if err != nil {
  126. return nil, err
  127. }
  128. req = req.WithContext(ctx)
  129. if err := c.applyEditors(ctx, req, reqEditors); err != nil {
  130. return nil, err
  131. }
  132. return c.Client.Do(req)
  133. }
  134. func (c *Client) PostSessionChat(ctx context.Context, body PostSessionChatJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) {
  135. req, err := NewPostSessionChatRequest(c.Server, body)
  136. if err != nil {
  137. return nil, err
  138. }
  139. req = req.WithContext(ctx)
  140. if err := c.applyEditors(ctx, req, reqEditors); err != nil {
  141. return nil, err
  142. }
  143. return c.Client.Do(req)
  144. }
  145. func (c *Client) PostSessionCreate(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error) {
  146. req, err := NewPostSessionCreateRequest(c.Server)
  147. if err != nil {
  148. return nil, err
  149. }
  150. req = req.WithContext(ctx)
  151. if err := c.applyEditors(ctx, req, reqEditors); err != nil {
  152. return nil, err
  153. }
  154. return c.Client.Do(req)
  155. }
  156. func (c *Client) PostSessionList(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error) {
  157. req, err := NewPostSessionListRequest(c.Server)
  158. if err != nil {
  159. return nil, err
  160. }
  161. req = req.WithContext(ctx)
  162. if err := c.applyEditors(ctx, req, reqEditors); err != nil {
  163. return nil, err
  164. }
  165. return c.Client.Do(req)
  166. }
  167. func (c *Client) PostSessionMessagesWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) {
  168. req, err := NewPostSessionMessagesRequestWithBody(c.Server, contentType, body)
  169. if err != nil {
  170. return nil, err
  171. }
  172. req = req.WithContext(ctx)
  173. if err := c.applyEditors(ctx, req, reqEditors); err != nil {
  174. return nil, err
  175. }
  176. return c.Client.Do(req)
  177. }
  178. func (c *Client) PostSessionMessages(ctx context.Context, body PostSessionMessagesJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) {
  179. req, err := NewPostSessionMessagesRequest(c.Server, body)
  180. if err != nil {
  181. return nil, err
  182. }
  183. req = req.WithContext(ctx)
  184. if err := c.applyEditors(ctx, req, reqEditors); err != nil {
  185. return nil, err
  186. }
  187. return c.Client.Do(req)
  188. }
  189. func (c *Client) PostSessionShareWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) {
  190. req, err := NewPostSessionShareRequestWithBody(c.Server, contentType, body)
  191. if err != nil {
  192. return nil, err
  193. }
  194. req = req.WithContext(ctx)
  195. if err := c.applyEditors(ctx, req, reqEditors); err != nil {
  196. return nil, err
  197. }
  198. return c.Client.Do(req)
  199. }
  200. func (c *Client) PostSessionShare(ctx context.Context, body PostSessionShareJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) {
  201. req, err := NewPostSessionShareRequest(c.Server, body)
  202. if err != nil {
  203. return nil, err
  204. }
  205. req = req.WithContext(ctx)
  206. if err := c.applyEditors(ctx, req, reqEditors); err != nil {
  207. return nil, err
  208. }
  209. return c.Client.Do(req)
  210. }
  211. // NewPostSessionChatRequest calls the generic PostSessionChat builder with application/json body
  212. func NewPostSessionChatRequest(server string, body PostSessionChatJSONRequestBody) (*http.Request, error) {
  213. var bodyReader io.Reader
  214. buf, err := json.Marshal(body)
  215. if err != nil {
  216. return nil, err
  217. }
  218. bodyReader = bytes.NewReader(buf)
  219. return NewPostSessionChatRequestWithBody(server, "application/json", bodyReader)
  220. }
  221. // NewPostSessionChatRequestWithBody generates requests for PostSessionChat with any type of body
  222. func NewPostSessionChatRequestWithBody(server string, contentType string, body io.Reader) (*http.Request, error) {
  223. var err error
  224. serverURL, err := url.Parse(server)
  225. if err != nil {
  226. return nil, err
  227. }
  228. operationPath := fmt.Sprintf("/session_chat")
  229. if operationPath[0] == '/' {
  230. operationPath = "." + operationPath
  231. }
  232. queryURL, err := serverURL.Parse(operationPath)
  233. if err != nil {
  234. return nil, err
  235. }
  236. req, err := http.NewRequest("POST", queryURL.String(), body)
  237. if err != nil {
  238. return nil, err
  239. }
  240. req.Header.Add("Content-Type", contentType)
  241. return req, nil
  242. }
  243. // NewPostSessionCreateRequest generates requests for PostSessionCreate
  244. func NewPostSessionCreateRequest(server string) (*http.Request, error) {
  245. var err error
  246. serverURL, err := url.Parse(server)
  247. if err != nil {
  248. return nil, err
  249. }
  250. operationPath := fmt.Sprintf("/session_create")
  251. if operationPath[0] == '/' {
  252. operationPath = "." + operationPath
  253. }
  254. queryURL, err := serverURL.Parse(operationPath)
  255. if err != nil {
  256. return nil, err
  257. }
  258. req, err := http.NewRequest("POST", queryURL.String(), nil)
  259. if err != nil {
  260. return nil, err
  261. }
  262. return req, nil
  263. }
  264. // NewPostSessionListRequest generates requests for PostSessionList
  265. func NewPostSessionListRequest(server string) (*http.Request, error) {
  266. var err error
  267. serverURL, err := url.Parse(server)
  268. if err != nil {
  269. return nil, err
  270. }
  271. operationPath := fmt.Sprintf("/session_list")
  272. if operationPath[0] == '/' {
  273. operationPath = "." + operationPath
  274. }
  275. queryURL, err := serverURL.Parse(operationPath)
  276. if err != nil {
  277. return nil, err
  278. }
  279. req, err := http.NewRequest("POST", queryURL.String(), nil)
  280. if err != nil {
  281. return nil, err
  282. }
  283. return req, nil
  284. }
  285. // NewPostSessionMessagesRequest calls the generic PostSessionMessages builder with application/json body
  286. func NewPostSessionMessagesRequest(server string, body PostSessionMessagesJSONRequestBody) (*http.Request, error) {
  287. var bodyReader io.Reader
  288. buf, err := json.Marshal(body)
  289. if err != nil {
  290. return nil, err
  291. }
  292. bodyReader = bytes.NewReader(buf)
  293. return NewPostSessionMessagesRequestWithBody(server, "application/json", bodyReader)
  294. }
  295. // NewPostSessionMessagesRequestWithBody generates requests for PostSessionMessages with any type of body
  296. func NewPostSessionMessagesRequestWithBody(server string, contentType string, body io.Reader) (*http.Request, error) {
  297. var err error
  298. serverURL, err := url.Parse(server)
  299. if err != nil {
  300. return nil, err
  301. }
  302. operationPath := fmt.Sprintf("/session_messages")
  303. if operationPath[0] == '/' {
  304. operationPath = "." + operationPath
  305. }
  306. queryURL, err := serverURL.Parse(operationPath)
  307. if err != nil {
  308. return nil, err
  309. }
  310. req, err := http.NewRequest("POST", queryURL.String(), body)
  311. if err != nil {
  312. return nil, err
  313. }
  314. req.Header.Add("Content-Type", contentType)
  315. return req, nil
  316. }
  317. // NewPostSessionShareRequest calls the generic PostSessionShare builder with application/json body
  318. func NewPostSessionShareRequest(server string, body PostSessionShareJSONRequestBody) (*http.Request, error) {
  319. var bodyReader io.Reader
  320. buf, err := json.Marshal(body)
  321. if err != nil {
  322. return nil, err
  323. }
  324. bodyReader = bytes.NewReader(buf)
  325. return NewPostSessionShareRequestWithBody(server, "application/json", bodyReader)
  326. }
  327. // NewPostSessionShareRequestWithBody generates requests for PostSessionShare with any type of body
  328. func NewPostSessionShareRequestWithBody(server string, contentType string, body io.Reader) (*http.Request, error) {
  329. var err error
  330. serverURL, err := url.Parse(server)
  331. if err != nil {
  332. return nil, err
  333. }
  334. operationPath := fmt.Sprintf("/session_share")
  335. if operationPath[0] == '/' {
  336. operationPath = "." + operationPath
  337. }
  338. queryURL, err := serverURL.Parse(operationPath)
  339. if err != nil {
  340. return nil, err
  341. }
  342. req, err := http.NewRequest("POST", queryURL.String(), body)
  343. if err != nil {
  344. return nil, err
  345. }
  346. req.Header.Add("Content-Type", contentType)
  347. return req, nil
  348. }
  349. func (c *Client) applyEditors(ctx context.Context, req *http.Request, additionalEditors []RequestEditorFn) error {
  350. for _, r := range c.RequestEditors {
  351. if err := r(ctx, req); err != nil {
  352. return err
  353. }
  354. }
  355. for _, r := range additionalEditors {
  356. if err := r(ctx, req); err != nil {
  357. return err
  358. }
  359. }
  360. return nil
  361. }
  362. // ClientWithResponses builds on ClientInterface to offer response payloads
  363. type ClientWithResponses struct {
  364. ClientInterface
  365. }
  366. // NewClientWithResponses creates a new ClientWithResponses, which wraps
  367. // Client with return type handling
  368. func NewClientWithResponses(server string, opts ...ClientOption) (*ClientWithResponses, error) {
  369. client, err := NewClient(server, opts...)
  370. if err != nil {
  371. return nil, err
  372. }
  373. return &ClientWithResponses{client}, nil
  374. }
  375. // WithBaseURL overrides the baseURL.
  376. func WithBaseURL(baseURL string) ClientOption {
  377. return func(c *Client) error {
  378. newBaseURL, err := url.Parse(baseURL)
  379. if err != nil {
  380. return err
  381. }
  382. c.Server = newBaseURL.String()
  383. return nil
  384. }
  385. }
  386. // ClientWithResponsesInterface is the interface specification for the client with responses above.
  387. type ClientWithResponsesInterface interface {
  388. // PostSessionChatWithBodyWithResponse request with any body
  389. PostSessionChatWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*PostSessionChatResponse, error)
  390. PostSessionChatWithResponse(ctx context.Context, body PostSessionChatJSONRequestBody, reqEditors ...RequestEditorFn) (*PostSessionChatResponse, error)
  391. // PostSessionCreateWithResponse request
  392. PostSessionCreateWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*PostSessionCreateResponse, error)
  393. // PostSessionListWithResponse request
  394. PostSessionListWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*PostSessionListResponse, error)
  395. // PostSessionMessagesWithBodyWithResponse request with any body
  396. PostSessionMessagesWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*PostSessionMessagesResponse, error)
  397. PostSessionMessagesWithResponse(ctx context.Context, body PostSessionMessagesJSONRequestBody, reqEditors ...RequestEditorFn) (*PostSessionMessagesResponse, error)
  398. // PostSessionShareWithBodyWithResponse request with any body
  399. PostSessionShareWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*PostSessionShareResponse, error)
  400. PostSessionShareWithResponse(ctx context.Context, body PostSessionShareJSONRequestBody, reqEditors ...RequestEditorFn) (*PostSessionShareResponse, error)
  401. }
  402. type PostSessionChatResponse struct {
  403. Body []byte
  404. HTTPResponse *http.Response
  405. }
  406. // Status returns HTTPResponse.Status
  407. func (r PostSessionChatResponse) Status() string {
  408. if r.HTTPResponse != nil {
  409. return r.HTTPResponse.Status
  410. }
  411. return http.StatusText(0)
  412. }
  413. // StatusCode returns HTTPResponse.StatusCode
  414. func (r PostSessionChatResponse) StatusCode() int {
  415. if r.HTTPResponse != nil {
  416. return r.HTTPResponse.StatusCode
  417. }
  418. return 0
  419. }
  420. type PostSessionCreateResponse struct {
  421. Body []byte
  422. HTTPResponse *http.Response
  423. JSON200 *SessionInfo
  424. }
  425. // Status returns HTTPResponse.Status
  426. func (r PostSessionCreateResponse) Status() string {
  427. if r.HTTPResponse != nil {
  428. return r.HTTPResponse.Status
  429. }
  430. return http.StatusText(0)
  431. }
  432. // StatusCode returns HTTPResponse.StatusCode
  433. func (r PostSessionCreateResponse) StatusCode() int {
  434. if r.HTTPResponse != nil {
  435. return r.HTTPResponse.StatusCode
  436. }
  437. return 0
  438. }
  439. type PostSessionListResponse struct {
  440. Body []byte
  441. HTTPResponse *http.Response
  442. JSON200 *[]struct {
  443. Id string `json:"id"`
  444. ShareID *string `json:"shareID,omitempty"`
  445. Title string `json:"title"`
  446. Tokens struct {
  447. Input float32 `json:"input"`
  448. Output float32 `json:"output"`
  449. Reasoning float32 `json:"reasoning"`
  450. } `json:"tokens"`
  451. }
  452. }
  453. // Status returns HTTPResponse.Status
  454. func (r PostSessionListResponse) Status() string {
  455. if r.HTTPResponse != nil {
  456. return r.HTTPResponse.Status
  457. }
  458. return http.StatusText(0)
  459. }
  460. // StatusCode returns HTTPResponse.StatusCode
  461. func (r PostSessionListResponse) StatusCode() int {
  462. if r.HTTPResponse != nil {
  463. return r.HTTPResponse.StatusCode
  464. }
  465. return 0
  466. }
  467. type PostSessionMessagesResponse struct {
  468. Body []byte
  469. HTTPResponse *http.Response
  470. JSON200 *interface{}
  471. }
  472. // Status returns HTTPResponse.Status
  473. func (r PostSessionMessagesResponse) Status() string {
  474. if r.HTTPResponse != nil {
  475. return r.HTTPResponse.Status
  476. }
  477. return http.StatusText(0)
  478. }
  479. // StatusCode returns HTTPResponse.StatusCode
  480. func (r PostSessionMessagesResponse) StatusCode() int {
  481. if r.HTTPResponse != nil {
  482. return r.HTTPResponse.StatusCode
  483. }
  484. return 0
  485. }
  486. type PostSessionShareResponse struct {
  487. Body []byte
  488. HTTPResponse *http.Response
  489. JSON200 *SessionInfo
  490. }
  491. // Status returns HTTPResponse.Status
  492. func (r PostSessionShareResponse) Status() string {
  493. if r.HTTPResponse != nil {
  494. return r.HTTPResponse.Status
  495. }
  496. return http.StatusText(0)
  497. }
  498. // StatusCode returns HTTPResponse.StatusCode
  499. func (r PostSessionShareResponse) StatusCode() int {
  500. if r.HTTPResponse != nil {
  501. return r.HTTPResponse.StatusCode
  502. }
  503. return 0
  504. }
  505. // PostSessionChatWithBodyWithResponse request with arbitrary body returning *PostSessionChatResponse
  506. func (c *ClientWithResponses) PostSessionChatWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*PostSessionChatResponse, error) {
  507. rsp, err := c.PostSessionChatWithBody(ctx, contentType, body, reqEditors...)
  508. if err != nil {
  509. return nil, err
  510. }
  511. return ParsePostSessionChatResponse(rsp)
  512. }
  513. func (c *ClientWithResponses) PostSessionChatWithResponse(ctx context.Context, body PostSessionChatJSONRequestBody, reqEditors ...RequestEditorFn) (*PostSessionChatResponse, error) {
  514. rsp, err := c.PostSessionChat(ctx, body, reqEditors...)
  515. if err != nil {
  516. return nil, err
  517. }
  518. return ParsePostSessionChatResponse(rsp)
  519. }
  520. // PostSessionCreateWithResponse request returning *PostSessionCreateResponse
  521. func (c *ClientWithResponses) PostSessionCreateWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*PostSessionCreateResponse, error) {
  522. rsp, err := c.PostSessionCreate(ctx, reqEditors...)
  523. if err != nil {
  524. return nil, err
  525. }
  526. return ParsePostSessionCreateResponse(rsp)
  527. }
  528. // PostSessionListWithResponse request returning *PostSessionListResponse
  529. func (c *ClientWithResponses) PostSessionListWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*PostSessionListResponse, error) {
  530. rsp, err := c.PostSessionList(ctx, reqEditors...)
  531. if err != nil {
  532. return nil, err
  533. }
  534. return ParsePostSessionListResponse(rsp)
  535. }
  536. // PostSessionMessagesWithBodyWithResponse request with arbitrary body returning *PostSessionMessagesResponse
  537. func (c *ClientWithResponses) PostSessionMessagesWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*PostSessionMessagesResponse, error) {
  538. rsp, err := c.PostSessionMessagesWithBody(ctx, contentType, body, reqEditors...)
  539. if err != nil {
  540. return nil, err
  541. }
  542. return ParsePostSessionMessagesResponse(rsp)
  543. }
  544. func (c *ClientWithResponses) PostSessionMessagesWithResponse(ctx context.Context, body PostSessionMessagesJSONRequestBody, reqEditors ...RequestEditorFn) (*PostSessionMessagesResponse, error) {
  545. rsp, err := c.PostSessionMessages(ctx, body, reqEditors...)
  546. if err != nil {
  547. return nil, err
  548. }
  549. return ParsePostSessionMessagesResponse(rsp)
  550. }
  551. // PostSessionShareWithBodyWithResponse request with arbitrary body returning *PostSessionShareResponse
  552. func (c *ClientWithResponses) PostSessionShareWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*PostSessionShareResponse, error) {
  553. rsp, err := c.PostSessionShareWithBody(ctx, contentType, body, reqEditors...)
  554. if err != nil {
  555. return nil, err
  556. }
  557. return ParsePostSessionShareResponse(rsp)
  558. }
  559. func (c *ClientWithResponses) PostSessionShareWithResponse(ctx context.Context, body PostSessionShareJSONRequestBody, reqEditors ...RequestEditorFn) (*PostSessionShareResponse, error) {
  560. rsp, err := c.PostSessionShare(ctx, body, reqEditors...)
  561. if err != nil {
  562. return nil, err
  563. }
  564. return ParsePostSessionShareResponse(rsp)
  565. }
  566. // ParsePostSessionChatResponse parses an HTTP response from a PostSessionChatWithResponse call
  567. func ParsePostSessionChatResponse(rsp *http.Response) (*PostSessionChatResponse, error) {
  568. bodyBytes, err := io.ReadAll(rsp.Body)
  569. defer func() { _ = rsp.Body.Close() }()
  570. if err != nil {
  571. return nil, err
  572. }
  573. response := &PostSessionChatResponse{
  574. Body: bodyBytes,
  575. HTTPResponse: rsp,
  576. }
  577. return response, nil
  578. }
  579. // ParsePostSessionCreateResponse parses an HTTP response from a PostSessionCreateWithResponse call
  580. func ParsePostSessionCreateResponse(rsp *http.Response) (*PostSessionCreateResponse, error) {
  581. bodyBytes, err := io.ReadAll(rsp.Body)
  582. defer func() { _ = rsp.Body.Close() }()
  583. if err != nil {
  584. return nil, err
  585. }
  586. response := &PostSessionCreateResponse{
  587. Body: bodyBytes,
  588. HTTPResponse: rsp,
  589. }
  590. switch {
  591. case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200:
  592. var dest SessionInfo
  593. if err := json.Unmarshal(bodyBytes, &dest); err != nil {
  594. return nil, err
  595. }
  596. response.JSON200 = &dest
  597. }
  598. return response, nil
  599. }
  600. // ParsePostSessionListResponse parses an HTTP response from a PostSessionListWithResponse call
  601. func ParsePostSessionListResponse(rsp *http.Response) (*PostSessionListResponse, error) {
  602. bodyBytes, err := io.ReadAll(rsp.Body)
  603. defer func() { _ = rsp.Body.Close() }()
  604. if err != nil {
  605. return nil, err
  606. }
  607. response := &PostSessionListResponse{
  608. Body: bodyBytes,
  609. HTTPResponse: rsp,
  610. }
  611. switch {
  612. case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200:
  613. var dest []struct {
  614. Id string `json:"id"`
  615. ShareID *string `json:"shareID,omitempty"`
  616. Title string `json:"title"`
  617. Tokens struct {
  618. Input float32 `json:"input"`
  619. Output float32 `json:"output"`
  620. Reasoning float32 `json:"reasoning"`
  621. } `json:"tokens"`
  622. }
  623. if err := json.Unmarshal(bodyBytes, &dest); err != nil {
  624. return nil, err
  625. }
  626. response.JSON200 = &dest
  627. }
  628. return response, nil
  629. }
  630. // ParsePostSessionMessagesResponse parses an HTTP response from a PostSessionMessagesWithResponse call
  631. func ParsePostSessionMessagesResponse(rsp *http.Response) (*PostSessionMessagesResponse, error) {
  632. bodyBytes, err := io.ReadAll(rsp.Body)
  633. defer func() { _ = rsp.Body.Close() }()
  634. if err != nil {
  635. return nil, err
  636. }
  637. response := &PostSessionMessagesResponse{
  638. Body: bodyBytes,
  639. HTTPResponse: rsp,
  640. }
  641. switch {
  642. case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200:
  643. var dest interface{}
  644. if err := json.Unmarshal(bodyBytes, &dest); err != nil {
  645. return nil, err
  646. }
  647. response.JSON200 = &dest
  648. }
  649. return response, nil
  650. }
  651. // ParsePostSessionShareResponse parses an HTTP response from a PostSessionShareWithResponse call
  652. func ParsePostSessionShareResponse(rsp *http.Response) (*PostSessionShareResponse, error) {
  653. bodyBytes, err := io.ReadAll(rsp.Body)
  654. defer func() { _ = rsp.Body.Close() }()
  655. if err != nil {
  656. return nil, err
  657. }
  658. response := &PostSessionShareResponse{
  659. Body: bodyBytes,
  660. HTTPResponse: rsp,
  661. }
  662. switch {
  663. case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200:
  664. var dest SessionInfo
  665. if err := json.Unmarshal(bodyBytes, &dest); err != nil {
  666. return nil, err
  667. }
  668. response.JSON200 = &dest
  669. }
  670. return response, nil
  671. }