generated-client.go 46 KB

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