| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953 |
- // Package client provides primitives to interact with the openapi HTTP API.
- //
- // Code generated by github.com/oapi-codegen/oapi-codegen/v2 version v2.4.1 DO NOT EDIT.
- package client
- import (
- "bytes"
- "context"
- "encoding/json"
- "errors"
- "fmt"
- "io"
- "net/http"
- "net/url"
- "strings"
- "github.com/oapi-codegen/runtime"
- )
- // Defines values for MessageInfoRole.
- const (
- Assistant MessageInfoRole = "assistant"
- System MessageInfoRole = "system"
- User MessageInfoRole = "user"
- )
- // Event defines model for Event.
- type Event struct {
- union json.RawMessage
- }
- // EventLspClientDiagnostics defines model for Event.lsp.client.diagnostics.
- type EventLspClientDiagnostics struct {
- Properties struct {
- Path string `json:"path"`
- ServerID string `json:"serverID"`
- } `json:"properties"`
- Type string `json:"type"`
- }
- // EventMessageUpdated defines model for Event.message.updated.
- type EventMessageUpdated struct {
- Properties struct {
- Info MessageInfo `json:"info"`
- } `json:"properties"`
- Type string `json:"type"`
- }
- // EventSessionUpdated defines model for Event.session.updated.
- type EventSessionUpdated struct {
- Properties struct {
- Info SessionInfo `json:"info"`
- } `json:"properties"`
- Type string `json:"type"`
- }
- // EventStorageWrite defines model for Event.storage.write.
- type EventStorageWrite struct {
- Properties struct {
- Content *interface{} `json:"content,omitempty"`
- Key string `json:"key"`
- } `json:"properties"`
- Type string `json:"type"`
- }
- // MessageInfo defines model for Message.Info.
- type MessageInfo struct {
- Id string `json:"id"`
- Metadata struct {
- Assistant *struct {
- Cost float32 `json:"cost"`
- ModelID string `json:"modelID"`
- ProviderID string `json:"providerID"`
- Summary *bool `json:"summary,omitempty"`
- Tokens struct {
- Input float32 `json:"input"`
- Output float32 `json:"output"`
- Reasoning float32 `json:"reasoning"`
- } `json:"tokens"`
- } `json:"assistant,omitempty"`
- SessionID string `json:"sessionID"`
- Time struct {
- Completed *float32 `json:"completed,omitempty"`
- Created float32 `json:"created"`
- } `json:"time"`
- Tool map[string]interface{} `json:"tool"`
- } `json:"metadata"`
- Parts []MessagePart `json:"parts"`
- Role MessageInfoRole `json:"role"`
- }
- // MessageInfoRole defines model for MessageInfo.Role.
- type MessageInfoRole string
- // MessagePart defines model for Message.Part.
- type MessagePart struct {
- union json.RawMessage
- }
- // MessagePartFile defines model for Message.Part.File.
- type MessagePartFile struct {
- Filename *string `json:"filename,omitempty"`
- MediaType string `json:"mediaType"`
- Type string `json:"type"`
- Url string `json:"url"`
- }
- // MessagePartReasoning defines model for Message.Part.Reasoning.
- type MessagePartReasoning struct {
- ProviderMetadata *map[string]interface{} `json:"providerMetadata,omitempty"`
- Text string `json:"text"`
- Type string `json:"type"`
- }
- // MessagePartSourceUrl defines model for Message.Part.SourceUrl.
- type MessagePartSourceUrl struct {
- ProviderMetadata *map[string]interface{} `json:"providerMetadata,omitempty"`
- SourceId string `json:"sourceId"`
- Title *string `json:"title,omitempty"`
- Type string `json:"type"`
- Url string `json:"url"`
- }
- // MessagePartStepStart defines model for Message.Part.StepStart.
- type MessagePartStepStart struct {
- Type string `json:"type"`
- }
- // MessagePartText defines model for Message.Part.Text.
- type MessagePartText struct {
- Text string `json:"text"`
- Type string `json:"type"`
- }
- // MessagePartToolInvocation defines model for Message.Part.ToolInvocation.
- type MessagePartToolInvocation struct {
- ToolInvocation MessageToolInvocation `json:"toolInvocation"`
- Type string `json:"type"`
- }
- // MessageToolInvocation defines model for Message.ToolInvocation.
- type MessageToolInvocation struct {
- union json.RawMessage
- }
- // MessageToolInvocationToolCall defines model for Message.ToolInvocation.ToolCall.
- type MessageToolInvocationToolCall struct {
- Args *interface{} `json:"args,omitempty"`
- State string `json:"state"`
- Step *float32 `json:"step,omitempty"`
- ToolCallId string `json:"toolCallId"`
- ToolName string `json:"toolName"`
- }
- // MessageToolInvocationToolPartialCall defines model for Message.ToolInvocation.ToolPartialCall.
- type MessageToolInvocationToolPartialCall struct {
- Args *interface{} `json:"args,omitempty"`
- State string `json:"state"`
- Step *float32 `json:"step,omitempty"`
- ToolCallId string `json:"toolCallId"`
- ToolName string `json:"toolName"`
- }
- // MessageToolInvocationToolResult defines model for Message.ToolInvocation.ToolResult.
- type MessageToolInvocationToolResult struct {
- Args *interface{} `json:"args,omitempty"`
- Result string `json:"result"`
- State string `json:"state"`
- Step *float32 `json:"step,omitempty"`
- ToolCallId string `json:"toolCallId"`
- ToolName string `json:"toolName"`
- }
- // ProviderInfo defines model for Provider.Info.
- type ProviderInfo struct {
- Id string `json:"id"`
- Models []ProviderModel `json:"models"`
- Name string `json:"name"`
- Options *map[string]interface{} `json:"options,omitempty"`
- }
- // ProviderModel defines model for Provider.Model.
- type ProviderModel struct {
- Attachment bool `json:"attachment"`
- ContextWindow float32 `json:"contextWindow"`
- Cost struct {
- Input float32 `json:"input"`
- InputCached float32 `json:"inputCached"`
- Output float32 `json:"output"`
- OutputCached float32 `json:"outputCached"`
- } `json:"cost"`
- Id string `json:"id"`
- MaxOutputTokens *float32 `json:"maxOutputTokens,omitempty"`
- Name *string `json:"name,omitempty"`
- Reasoning *bool `json:"reasoning,omitempty"`
- }
- // SessionInfo defines model for session.info.
- type SessionInfo struct {
- Id string `json:"id"`
- Share *struct {
- Secret string `json:"secret"`
- Url string `json:"url"`
- } `json:"share,omitempty"`
- Time struct {
- Created float32 `json:"created"`
- Updated float32 `json:"updated"`
- } `json:"time"`
- Title string `json:"title"`
- }
- // PostSessionAbortJSONBody defines parameters for PostSessionAbort.
- type PostSessionAbortJSONBody struct {
- SessionID string `json:"sessionID"`
- }
- // PostSessionChatJSONBody defines parameters for PostSessionChat.
- type PostSessionChatJSONBody struct {
- ModelID string `json:"modelID"`
- Parts []MessagePart `json:"parts"`
- ProviderID string `json:"providerID"`
- SessionID string `json:"sessionID"`
- }
- // PostSessionMessagesJSONBody defines parameters for PostSessionMessages.
- type PostSessionMessagesJSONBody struct {
- SessionID string `json:"sessionID"`
- }
- // PostSessionShareJSONBody defines parameters for PostSessionShare.
- type PostSessionShareJSONBody struct {
- SessionID string `json:"sessionID"`
- }
- // PostSessionSummarizeJSONBody defines parameters for PostSessionSummarize.
- type PostSessionSummarizeJSONBody struct {
- ModelID string `json:"modelID"`
- ProviderID string `json:"providerID"`
- SessionID string `json:"sessionID"`
- }
- // PostSessionAbortJSONRequestBody defines body for PostSessionAbort for application/json ContentType.
- type PostSessionAbortJSONRequestBody PostSessionAbortJSONBody
- // PostSessionChatJSONRequestBody defines body for PostSessionChat for application/json ContentType.
- type PostSessionChatJSONRequestBody PostSessionChatJSONBody
- // PostSessionMessagesJSONRequestBody defines body for PostSessionMessages for application/json ContentType.
- type PostSessionMessagesJSONRequestBody PostSessionMessagesJSONBody
- // PostSessionShareJSONRequestBody defines body for PostSessionShare for application/json ContentType.
- type PostSessionShareJSONRequestBody PostSessionShareJSONBody
- // PostSessionSummarizeJSONRequestBody defines body for PostSessionSummarize for application/json ContentType.
- type PostSessionSummarizeJSONRequestBody PostSessionSummarizeJSONBody
- // AsEventStorageWrite returns the union data inside the Event as a EventStorageWrite
- func (t Event) AsEventStorageWrite() (EventStorageWrite, error) {
- var body EventStorageWrite
- err := json.Unmarshal(t.union, &body)
- return body, err
- }
- // FromEventStorageWrite overwrites any union data inside the Event as the provided EventStorageWrite
- func (t *Event) FromEventStorageWrite(v EventStorageWrite) error {
- v.Type = "storage.write"
- b, err := json.Marshal(v)
- t.union = b
- return err
- }
- // MergeEventStorageWrite performs a merge with any union data inside the Event, using the provided EventStorageWrite
- func (t *Event) MergeEventStorageWrite(v EventStorageWrite) error {
- v.Type = "storage.write"
- b, err := json.Marshal(v)
- if err != nil {
- return err
- }
- merged, err := runtime.JSONMerge(t.union, b)
- t.union = merged
- return err
- }
- // AsEventLspClientDiagnostics returns the union data inside the Event as a EventLspClientDiagnostics
- func (t Event) AsEventLspClientDiagnostics() (EventLspClientDiagnostics, error) {
- var body EventLspClientDiagnostics
- err := json.Unmarshal(t.union, &body)
- return body, err
- }
- // FromEventLspClientDiagnostics overwrites any union data inside the Event as the provided EventLspClientDiagnostics
- func (t *Event) FromEventLspClientDiagnostics(v EventLspClientDiagnostics) error {
- v.Type = "lsp.client.diagnostics"
- b, err := json.Marshal(v)
- t.union = b
- return err
- }
- // MergeEventLspClientDiagnostics performs a merge with any union data inside the Event, using the provided EventLspClientDiagnostics
- func (t *Event) MergeEventLspClientDiagnostics(v EventLspClientDiagnostics) error {
- v.Type = "lsp.client.diagnostics"
- b, err := json.Marshal(v)
- if err != nil {
- return err
- }
- merged, err := runtime.JSONMerge(t.union, b)
- t.union = merged
- return err
- }
- // AsEventMessageUpdated returns the union data inside the Event as a EventMessageUpdated
- func (t Event) AsEventMessageUpdated() (EventMessageUpdated, error) {
- var body EventMessageUpdated
- err := json.Unmarshal(t.union, &body)
- return body, err
- }
- // FromEventMessageUpdated overwrites any union data inside the Event as the provided EventMessageUpdated
- func (t *Event) FromEventMessageUpdated(v EventMessageUpdated) error {
- v.Type = "message.updated"
- b, err := json.Marshal(v)
- t.union = b
- return err
- }
- // MergeEventMessageUpdated performs a merge with any union data inside the Event, using the provided EventMessageUpdated
- func (t *Event) MergeEventMessageUpdated(v EventMessageUpdated) error {
- v.Type = "message.updated"
- b, err := json.Marshal(v)
- if err != nil {
- return err
- }
- merged, err := runtime.JSONMerge(t.union, b)
- t.union = merged
- return err
- }
- // AsEventSessionUpdated returns the union data inside the Event as a EventSessionUpdated
- func (t Event) AsEventSessionUpdated() (EventSessionUpdated, error) {
- var body EventSessionUpdated
- err := json.Unmarshal(t.union, &body)
- return body, err
- }
- // FromEventSessionUpdated overwrites any union data inside the Event as the provided EventSessionUpdated
- func (t *Event) FromEventSessionUpdated(v EventSessionUpdated) error {
- v.Type = "session.updated"
- b, err := json.Marshal(v)
- t.union = b
- return err
- }
- // MergeEventSessionUpdated performs a merge with any union data inside the Event, using the provided EventSessionUpdated
- func (t *Event) MergeEventSessionUpdated(v EventSessionUpdated) error {
- v.Type = "session.updated"
- b, err := json.Marshal(v)
- if err != nil {
- return err
- }
- merged, err := runtime.JSONMerge(t.union, b)
- t.union = merged
- return err
- }
- func (t Event) Discriminator() (string, error) {
- var discriminator struct {
- Discriminator string `json:"type"`
- }
- err := json.Unmarshal(t.union, &discriminator)
- return discriminator.Discriminator, err
- }
- func (t Event) ValueByDiscriminator() (interface{}, error) {
- discriminator, err := t.Discriminator()
- if err != nil {
- return nil, err
- }
- switch discriminator {
- case "lsp.client.diagnostics":
- return t.AsEventLspClientDiagnostics()
- case "message.updated":
- return t.AsEventMessageUpdated()
- case "session.updated":
- return t.AsEventSessionUpdated()
- case "storage.write":
- return t.AsEventStorageWrite()
- default:
- return nil, errors.New("unknown discriminator value: " + discriminator)
- }
- }
- func (t Event) MarshalJSON() ([]byte, error) {
- b, err := t.union.MarshalJSON()
- return b, err
- }
- func (t *Event) UnmarshalJSON(b []byte) error {
- err := t.union.UnmarshalJSON(b)
- return err
- }
- // AsMessagePartText returns the union data inside the MessagePart as a MessagePartText
- func (t MessagePart) AsMessagePartText() (MessagePartText, error) {
- var body MessagePartText
- err := json.Unmarshal(t.union, &body)
- return body, err
- }
- // FromMessagePartText overwrites any union data inside the MessagePart as the provided MessagePartText
- func (t *MessagePart) FromMessagePartText(v MessagePartText) error {
- v.Type = "text"
- b, err := json.Marshal(v)
- t.union = b
- return err
- }
- // MergeMessagePartText performs a merge with any union data inside the MessagePart, using the provided MessagePartText
- func (t *MessagePart) MergeMessagePartText(v MessagePartText) error {
- v.Type = "text"
- b, err := json.Marshal(v)
- if err != nil {
- return err
- }
- merged, err := runtime.JSONMerge(t.union, b)
- t.union = merged
- return err
- }
- // AsMessagePartReasoning returns the union data inside the MessagePart as a MessagePartReasoning
- func (t MessagePart) AsMessagePartReasoning() (MessagePartReasoning, error) {
- var body MessagePartReasoning
- err := json.Unmarshal(t.union, &body)
- return body, err
- }
- // FromMessagePartReasoning overwrites any union data inside the MessagePart as the provided MessagePartReasoning
- func (t *MessagePart) FromMessagePartReasoning(v MessagePartReasoning) error {
- v.Type = "reasoning"
- b, err := json.Marshal(v)
- t.union = b
- return err
- }
- // MergeMessagePartReasoning performs a merge with any union data inside the MessagePart, using the provided MessagePartReasoning
- func (t *MessagePart) MergeMessagePartReasoning(v MessagePartReasoning) error {
- v.Type = "reasoning"
- b, err := json.Marshal(v)
- if err != nil {
- return err
- }
- merged, err := runtime.JSONMerge(t.union, b)
- t.union = merged
- return err
- }
- // AsMessagePartToolInvocation returns the union data inside the MessagePart as a MessagePartToolInvocation
- func (t MessagePart) AsMessagePartToolInvocation() (MessagePartToolInvocation, error) {
- var body MessagePartToolInvocation
- err := json.Unmarshal(t.union, &body)
- return body, err
- }
- // FromMessagePartToolInvocation overwrites any union data inside the MessagePart as the provided MessagePartToolInvocation
- func (t *MessagePart) FromMessagePartToolInvocation(v MessagePartToolInvocation) error {
- v.Type = "tool-invocation"
- b, err := json.Marshal(v)
- t.union = b
- return err
- }
- // MergeMessagePartToolInvocation performs a merge with any union data inside the MessagePart, using the provided MessagePartToolInvocation
- func (t *MessagePart) MergeMessagePartToolInvocation(v MessagePartToolInvocation) error {
- v.Type = "tool-invocation"
- b, err := json.Marshal(v)
- if err != nil {
- return err
- }
- merged, err := runtime.JSONMerge(t.union, b)
- t.union = merged
- return err
- }
- // AsMessagePartSourceUrl returns the union data inside the MessagePart as a MessagePartSourceUrl
- func (t MessagePart) AsMessagePartSourceUrl() (MessagePartSourceUrl, error) {
- var body MessagePartSourceUrl
- err := json.Unmarshal(t.union, &body)
- return body, err
- }
- // FromMessagePartSourceUrl overwrites any union data inside the MessagePart as the provided MessagePartSourceUrl
- func (t *MessagePart) FromMessagePartSourceUrl(v MessagePartSourceUrl) error {
- v.Type = "source-url"
- b, err := json.Marshal(v)
- t.union = b
- return err
- }
- // MergeMessagePartSourceUrl performs a merge with any union data inside the MessagePart, using the provided MessagePartSourceUrl
- func (t *MessagePart) MergeMessagePartSourceUrl(v MessagePartSourceUrl) error {
- v.Type = "source-url"
- b, err := json.Marshal(v)
- if err != nil {
- return err
- }
- merged, err := runtime.JSONMerge(t.union, b)
- t.union = merged
- return err
- }
- // AsMessagePartFile returns the union data inside the MessagePart as a MessagePartFile
- func (t MessagePart) AsMessagePartFile() (MessagePartFile, error) {
- var body MessagePartFile
- err := json.Unmarshal(t.union, &body)
- return body, err
- }
- // FromMessagePartFile overwrites any union data inside the MessagePart as the provided MessagePartFile
- func (t *MessagePart) FromMessagePartFile(v MessagePartFile) error {
- v.Type = "file"
- b, err := json.Marshal(v)
- t.union = b
- return err
- }
- // MergeMessagePartFile performs a merge with any union data inside the MessagePart, using the provided MessagePartFile
- func (t *MessagePart) MergeMessagePartFile(v MessagePartFile) error {
- v.Type = "file"
- b, err := json.Marshal(v)
- if err != nil {
- return err
- }
- merged, err := runtime.JSONMerge(t.union, b)
- t.union = merged
- return err
- }
- // AsMessagePartStepStart returns the union data inside the MessagePart as a MessagePartStepStart
- func (t MessagePart) AsMessagePartStepStart() (MessagePartStepStart, error) {
- var body MessagePartStepStart
- err := json.Unmarshal(t.union, &body)
- return body, err
- }
- // FromMessagePartStepStart overwrites any union data inside the MessagePart as the provided MessagePartStepStart
- func (t *MessagePart) FromMessagePartStepStart(v MessagePartStepStart) error {
- v.Type = "step-start"
- b, err := json.Marshal(v)
- t.union = b
- return err
- }
- // MergeMessagePartStepStart performs a merge with any union data inside the MessagePart, using the provided MessagePartStepStart
- func (t *MessagePart) MergeMessagePartStepStart(v MessagePartStepStart) error {
- v.Type = "step-start"
- b, err := json.Marshal(v)
- if err != nil {
- return err
- }
- merged, err := runtime.JSONMerge(t.union, b)
- t.union = merged
- return err
- }
- func (t MessagePart) Discriminator() (string, error) {
- var discriminator struct {
- Discriminator string `json:"type"`
- }
- err := json.Unmarshal(t.union, &discriminator)
- return discriminator.Discriminator, err
- }
- func (t MessagePart) ValueByDiscriminator() (interface{}, error) {
- discriminator, err := t.Discriminator()
- if err != nil {
- return nil, err
- }
- switch discriminator {
- case "file":
- return t.AsMessagePartFile()
- case "reasoning":
- return t.AsMessagePartReasoning()
- case "source-url":
- return t.AsMessagePartSourceUrl()
- case "step-start":
- return t.AsMessagePartStepStart()
- case "text":
- return t.AsMessagePartText()
- case "tool-invocation":
- return t.AsMessagePartToolInvocation()
- default:
- return nil, errors.New("unknown discriminator value: " + discriminator)
- }
- }
- func (t MessagePart) MarshalJSON() ([]byte, error) {
- b, err := t.union.MarshalJSON()
- return b, err
- }
- func (t *MessagePart) UnmarshalJSON(b []byte) error {
- err := t.union.UnmarshalJSON(b)
- return err
- }
- // AsMessageToolInvocationToolCall returns the union data inside the MessageToolInvocation as a MessageToolInvocationToolCall
- func (t MessageToolInvocation) AsMessageToolInvocationToolCall() (MessageToolInvocationToolCall, error) {
- var body MessageToolInvocationToolCall
- err := json.Unmarshal(t.union, &body)
- return body, err
- }
- // FromMessageToolInvocationToolCall overwrites any union data inside the MessageToolInvocation as the provided MessageToolInvocationToolCall
- func (t *MessageToolInvocation) FromMessageToolInvocationToolCall(v MessageToolInvocationToolCall) error {
- v.State = "call"
- b, err := json.Marshal(v)
- t.union = b
- return err
- }
- // MergeMessageToolInvocationToolCall performs a merge with any union data inside the MessageToolInvocation, using the provided MessageToolInvocationToolCall
- func (t *MessageToolInvocation) MergeMessageToolInvocationToolCall(v MessageToolInvocationToolCall) error {
- v.State = "call"
- b, err := json.Marshal(v)
- if err != nil {
- return err
- }
- merged, err := runtime.JSONMerge(t.union, b)
- t.union = merged
- return err
- }
- // AsMessageToolInvocationToolPartialCall returns the union data inside the MessageToolInvocation as a MessageToolInvocationToolPartialCall
- func (t MessageToolInvocation) AsMessageToolInvocationToolPartialCall() (MessageToolInvocationToolPartialCall, error) {
- var body MessageToolInvocationToolPartialCall
- err := json.Unmarshal(t.union, &body)
- return body, err
- }
- // FromMessageToolInvocationToolPartialCall overwrites any union data inside the MessageToolInvocation as the provided MessageToolInvocationToolPartialCall
- func (t *MessageToolInvocation) FromMessageToolInvocationToolPartialCall(v MessageToolInvocationToolPartialCall) error {
- v.State = "partial-call"
- b, err := json.Marshal(v)
- t.union = b
- return err
- }
- // MergeMessageToolInvocationToolPartialCall performs a merge with any union data inside the MessageToolInvocation, using the provided MessageToolInvocationToolPartialCall
- func (t *MessageToolInvocation) MergeMessageToolInvocationToolPartialCall(v MessageToolInvocationToolPartialCall) error {
- v.State = "partial-call"
- b, err := json.Marshal(v)
- if err != nil {
- return err
- }
- merged, err := runtime.JSONMerge(t.union, b)
- t.union = merged
- return err
- }
- // AsMessageToolInvocationToolResult returns the union data inside the MessageToolInvocation as a MessageToolInvocationToolResult
- func (t MessageToolInvocation) AsMessageToolInvocationToolResult() (MessageToolInvocationToolResult, error) {
- var body MessageToolInvocationToolResult
- err := json.Unmarshal(t.union, &body)
- return body, err
- }
- // FromMessageToolInvocationToolResult overwrites any union data inside the MessageToolInvocation as the provided MessageToolInvocationToolResult
- func (t *MessageToolInvocation) FromMessageToolInvocationToolResult(v MessageToolInvocationToolResult) error {
- v.State = "result"
- b, err := json.Marshal(v)
- t.union = b
- return err
- }
- // MergeMessageToolInvocationToolResult performs a merge with any union data inside the MessageToolInvocation, using the provided MessageToolInvocationToolResult
- func (t *MessageToolInvocation) MergeMessageToolInvocationToolResult(v MessageToolInvocationToolResult) error {
- v.State = "result"
- b, err := json.Marshal(v)
- if err != nil {
- return err
- }
- merged, err := runtime.JSONMerge(t.union, b)
- t.union = merged
- return err
- }
- func (t MessageToolInvocation) Discriminator() (string, error) {
- var discriminator struct {
- Discriminator string `json:"state"`
- }
- err := json.Unmarshal(t.union, &discriminator)
- return discriminator.Discriminator, err
- }
- func (t MessageToolInvocation) ValueByDiscriminator() (interface{}, error) {
- discriminator, err := t.Discriminator()
- if err != nil {
- return nil, err
- }
- switch discriminator {
- case "call":
- return t.AsMessageToolInvocationToolCall()
- case "partial-call":
- return t.AsMessageToolInvocationToolPartialCall()
- case "result":
- return t.AsMessageToolInvocationToolResult()
- default:
- return nil, errors.New("unknown discriminator value: " + discriminator)
- }
- }
- func (t MessageToolInvocation) MarshalJSON() ([]byte, error) {
- b, err := t.union.MarshalJSON()
- return b, err
- }
- func (t *MessageToolInvocation) UnmarshalJSON(b []byte) error {
- err := t.union.UnmarshalJSON(b)
- return err
- }
- // RequestEditorFn is the function signature for the RequestEditor callback function
- type RequestEditorFn func(ctx context.Context, req *http.Request) error
- // Doer performs HTTP requests.
- //
- // The standard http.Client implements this interface.
- type HttpRequestDoer interface {
- Do(req *http.Request) (*http.Response, error)
- }
- // Client which conforms to the OpenAPI3 specification for this service.
- type Client struct {
- // The endpoint of the server conforming to this interface, with scheme,
- // https://api.deepmap.com for example. This can contain a path relative
- // to the server, such as https://api.deepmap.com/dev-test, and all the
- // paths in the swagger spec will be appended to the server.
- Server string
- // Doer for performing requests, typically a *http.Client with any
- // customized settings, such as certificate chains.
- Client HttpRequestDoer
- // A list of callbacks for modifying requests which are generated before sending over
- // the network.
- RequestEditors []RequestEditorFn
- }
- // ClientOption allows setting custom parameters during construction
- type ClientOption func(*Client) error
- // Creates a new Client, with reasonable defaults
- func NewClient(server string, opts ...ClientOption) (*Client, error) {
- // create a client with sane default values
- client := Client{
- Server: server,
- }
- // mutate client and add all optional params
- for _, o := range opts {
- if err := o(&client); err != nil {
- return nil, err
- }
- }
- // ensure the server URL always has a trailing slash
- if !strings.HasSuffix(client.Server, "/") {
- client.Server += "/"
- }
- // create httpClient, if not already present
- if client.Client == nil {
- client.Client = &http.Client{}
- }
- return &client, nil
- }
- // WithHTTPClient allows overriding the default Doer, which is
- // automatically created using http.Client. This is useful for tests.
- func WithHTTPClient(doer HttpRequestDoer) ClientOption {
- return func(c *Client) error {
- c.Client = doer
- return nil
- }
- }
- // WithRequestEditorFn allows setting up a callback function, which will be
- // called right before sending the request. This can be used to mutate the request.
- func WithRequestEditorFn(fn RequestEditorFn) ClientOption {
- return func(c *Client) error {
- c.RequestEditors = append(c.RequestEditors, fn)
- return nil
- }
- }
- // The interface specification for the client above.
- type ClientInterface interface {
- // GetEvent request
- GetEvent(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error)
- // PostProviderList request
- PostProviderList(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error)
- // PostSessionAbortWithBody request with any body
- PostSessionAbortWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error)
- PostSessionAbort(ctx context.Context, body PostSessionAbortJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error)
- // PostSessionChatWithBody request with any body
- PostSessionChatWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error)
- PostSessionChat(ctx context.Context, body PostSessionChatJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error)
- // PostSessionCreate request
- PostSessionCreate(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error)
- // PostSessionList request
- PostSessionList(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error)
- // PostSessionMessagesWithBody request with any body
- PostSessionMessagesWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error)
- PostSessionMessages(ctx context.Context, body PostSessionMessagesJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error)
- // PostSessionShareWithBody request with any body
- PostSessionShareWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error)
- PostSessionShare(ctx context.Context, body PostSessionShareJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error)
- // PostSessionSummarizeWithBody request with any body
- PostSessionSummarizeWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error)
- PostSessionSummarize(ctx context.Context, body PostSessionSummarizeJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error)
- }
- func (c *Client) GetEvent(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error) {
- req, err := NewGetEventRequest(c.Server)
- if err != nil {
- return nil, err
- }
- req = req.WithContext(ctx)
- if err := c.applyEditors(ctx, req, reqEditors); err != nil {
- return nil, err
- }
- return c.Client.Do(req)
- }
- func (c *Client) PostProviderList(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error) {
- req, err := NewPostProviderListRequest(c.Server)
- if err != nil {
- return nil, err
- }
- req = req.WithContext(ctx)
- if err := c.applyEditors(ctx, req, reqEditors); err != nil {
- return nil, err
- }
- return c.Client.Do(req)
- }
- func (c *Client) PostSessionAbortWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) {
- req, err := NewPostSessionAbortRequestWithBody(c.Server, contentType, body)
- if err != nil {
- return nil, err
- }
- req = req.WithContext(ctx)
- if err := c.applyEditors(ctx, req, reqEditors); err != nil {
- return nil, err
- }
- return c.Client.Do(req)
- }
- func (c *Client) PostSessionAbort(ctx context.Context, body PostSessionAbortJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) {
- req, err := NewPostSessionAbortRequest(c.Server, body)
- if err != nil {
- return nil, err
- }
- req = req.WithContext(ctx)
- if err := c.applyEditors(ctx, req, reqEditors); err != nil {
- return nil, err
- }
- return c.Client.Do(req)
- }
- func (c *Client) PostSessionChatWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) {
- req, err := NewPostSessionChatRequestWithBody(c.Server, contentType, body)
- if err != nil {
- return nil, err
- }
- req = req.WithContext(ctx)
- if err := c.applyEditors(ctx, req, reqEditors); err != nil {
- return nil, err
- }
- return c.Client.Do(req)
- }
- func (c *Client) PostSessionChat(ctx context.Context, body PostSessionChatJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) {
- req, err := NewPostSessionChatRequest(c.Server, body)
- if err != nil {
- return nil, err
- }
- req = req.WithContext(ctx)
- if err := c.applyEditors(ctx, req, reqEditors); err != nil {
- return nil, err
- }
- return c.Client.Do(req)
- }
- func (c *Client) PostSessionCreate(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error) {
- req, err := NewPostSessionCreateRequest(c.Server)
- if err != nil {
- return nil, err
- }
- req = req.WithContext(ctx)
- if err := c.applyEditors(ctx, req, reqEditors); err != nil {
- return nil, err
- }
- return c.Client.Do(req)
- }
- func (c *Client) PostSessionList(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error) {
- req, err := NewPostSessionListRequest(c.Server)
- if err != nil {
- return nil, err
- }
- req = req.WithContext(ctx)
- if err := c.applyEditors(ctx, req, reqEditors); err != nil {
- return nil, err
- }
- return c.Client.Do(req)
- }
- func (c *Client) PostSessionMessagesWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) {
- req, err := NewPostSessionMessagesRequestWithBody(c.Server, contentType, body)
- if err != nil {
- return nil, err
- }
- req = req.WithContext(ctx)
- if err := c.applyEditors(ctx, req, reqEditors); err != nil {
- return nil, err
- }
- return c.Client.Do(req)
- }
- func (c *Client) PostSessionMessages(ctx context.Context, body PostSessionMessagesJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) {
- req, err := NewPostSessionMessagesRequest(c.Server, body)
- if err != nil {
- return nil, err
- }
- req = req.WithContext(ctx)
- if err := c.applyEditors(ctx, req, reqEditors); err != nil {
- return nil, err
- }
- return c.Client.Do(req)
- }
- func (c *Client) PostSessionShareWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) {
- req, err := NewPostSessionShareRequestWithBody(c.Server, contentType, body)
- if err != nil {
- return nil, err
- }
- req = req.WithContext(ctx)
- if err := c.applyEditors(ctx, req, reqEditors); err != nil {
- return nil, err
- }
- return c.Client.Do(req)
- }
- func (c *Client) PostSessionShare(ctx context.Context, body PostSessionShareJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) {
- req, err := NewPostSessionShareRequest(c.Server, body)
- if err != nil {
- return nil, err
- }
- req = req.WithContext(ctx)
- if err := c.applyEditors(ctx, req, reqEditors); err != nil {
- return nil, err
- }
- return c.Client.Do(req)
- }
- func (c *Client) PostSessionSummarizeWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) {
- req, err := NewPostSessionSummarizeRequestWithBody(c.Server, contentType, body)
- if err != nil {
- return nil, err
- }
- req = req.WithContext(ctx)
- if err := c.applyEditors(ctx, req, reqEditors); err != nil {
- return nil, err
- }
- return c.Client.Do(req)
- }
- func (c *Client) PostSessionSummarize(ctx context.Context, body PostSessionSummarizeJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) {
- req, err := NewPostSessionSummarizeRequest(c.Server, body)
- if err != nil {
- return nil, err
- }
- req = req.WithContext(ctx)
- if err := c.applyEditors(ctx, req, reqEditors); err != nil {
- return nil, err
- }
- return c.Client.Do(req)
- }
- // NewGetEventRequest generates requests for GetEvent
- func NewGetEventRequest(server string) (*http.Request, error) {
- var err error
- serverURL, err := url.Parse(server)
- if err != nil {
- return nil, err
- }
- operationPath := fmt.Sprintf("/event")
- if operationPath[0] == '/' {
- operationPath = "." + operationPath
- }
- queryURL, err := serverURL.Parse(operationPath)
- if err != nil {
- return nil, err
- }
- req, err := http.NewRequest("GET", queryURL.String(), nil)
- if err != nil {
- return nil, err
- }
- return req, nil
- }
- // NewPostProviderListRequest generates requests for PostProviderList
- func NewPostProviderListRequest(server string) (*http.Request, error) {
- var err error
- serverURL, err := url.Parse(server)
- if err != nil {
- return nil, err
- }
- operationPath := fmt.Sprintf("/provider_list")
- if operationPath[0] == '/' {
- operationPath = "." + operationPath
- }
- queryURL, err := serverURL.Parse(operationPath)
- if err != nil {
- return nil, err
- }
- req, err := http.NewRequest("POST", queryURL.String(), nil)
- if err != nil {
- return nil, err
- }
- return req, nil
- }
- // NewPostSessionAbortRequest calls the generic PostSessionAbort builder with application/json body
- func NewPostSessionAbortRequest(server string, body PostSessionAbortJSONRequestBody) (*http.Request, error) {
- var bodyReader io.Reader
- buf, err := json.Marshal(body)
- if err != nil {
- return nil, err
- }
- bodyReader = bytes.NewReader(buf)
- return NewPostSessionAbortRequestWithBody(server, "application/json", bodyReader)
- }
- // NewPostSessionAbortRequestWithBody generates requests for PostSessionAbort with any type of body
- func NewPostSessionAbortRequestWithBody(server string, contentType string, body io.Reader) (*http.Request, error) {
- var err error
- serverURL, err := url.Parse(server)
- if err != nil {
- return nil, err
- }
- operationPath := fmt.Sprintf("/session_abort")
- if operationPath[0] == '/' {
- operationPath = "." + operationPath
- }
- queryURL, err := serverURL.Parse(operationPath)
- if err != nil {
- return nil, err
- }
- req, err := http.NewRequest("POST", queryURL.String(), body)
- if err != nil {
- return nil, err
- }
- req.Header.Add("Content-Type", contentType)
- return req, nil
- }
- // NewPostSessionChatRequest calls the generic PostSessionChat builder with application/json body
- func NewPostSessionChatRequest(server string, body PostSessionChatJSONRequestBody) (*http.Request, error) {
- var bodyReader io.Reader
- buf, err := json.Marshal(body)
- if err != nil {
- return nil, err
- }
- bodyReader = bytes.NewReader(buf)
- return NewPostSessionChatRequestWithBody(server, "application/json", bodyReader)
- }
- // NewPostSessionChatRequestWithBody generates requests for PostSessionChat with any type of body
- func NewPostSessionChatRequestWithBody(server string, contentType string, body io.Reader) (*http.Request, error) {
- var err error
- serverURL, err := url.Parse(server)
- if err != nil {
- return nil, err
- }
- operationPath := fmt.Sprintf("/session_chat")
- if operationPath[0] == '/' {
- operationPath = "." + operationPath
- }
- queryURL, err := serverURL.Parse(operationPath)
- if err != nil {
- return nil, err
- }
- req, err := http.NewRequest("POST", queryURL.String(), body)
- if err != nil {
- return nil, err
- }
- req.Header.Add("Content-Type", contentType)
- return req, nil
- }
- // NewPostSessionCreateRequest generates requests for PostSessionCreate
- func NewPostSessionCreateRequest(server string) (*http.Request, error) {
- var err error
- serverURL, err := url.Parse(server)
- if err != nil {
- return nil, err
- }
- operationPath := fmt.Sprintf("/session_create")
- if operationPath[0] == '/' {
- operationPath = "." + operationPath
- }
- queryURL, err := serverURL.Parse(operationPath)
- if err != nil {
- return nil, err
- }
- req, err := http.NewRequest("POST", queryURL.String(), nil)
- if err != nil {
- return nil, err
- }
- return req, nil
- }
- // NewPostSessionListRequest generates requests for PostSessionList
- func NewPostSessionListRequest(server string) (*http.Request, error) {
- var err error
- serverURL, err := url.Parse(server)
- if err != nil {
- return nil, err
- }
- operationPath := fmt.Sprintf("/session_list")
- if operationPath[0] == '/' {
- operationPath = "." + operationPath
- }
- queryURL, err := serverURL.Parse(operationPath)
- if err != nil {
- return nil, err
- }
- req, err := http.NewRequest("POST", queryURL.String(), nil)
- if err != nil {
- return nil, err
- }
- return req, nil
- }
- // NewPostSessionMessagesRequest calls the generic PostSessionMessages builder with application/json body
- func NewPostSessionMessagesRequest(server string, body PostSessionMessagesJSONRequestBody) (*http.Request, error) {
- var bodyReader io.Reader
- buf, err := json.Marshal(body)
- if err != nil {
- return nil, err
- }
- bodyReader = bytes.NewReader(buf)
- return NewPostSessionMessagesRequestWithBody(server, "application/json", bodyReader)
- }
- // NewPostSessionMessagesRequestWithBody generates requests for PostSessionMessages with any type of body
- func NewPostSessionMessagesRequestWithBody(server string, contentType string, body io.Reader) (*http.Request, error) {
- var err error
- serverURL, err := url.Parse(server)
- if err != nil {
- return nil, err
- }
- operationPath := fmt.Sprintf("/session_messages")
- if operationPath[0] == '/' {
- operationPath = "." + operationPath
- }
- queryURL, err := serverURL.Parse(operationPath)
- if err != nil {
- return nil, err
- }
- req, err := http.NewRequest("POST", queryURL.String(), body)
- if err != nil {
- return nil, err
- }
- req.Header.Add("Content-Type", contentType)
- return req, nil
- }
- // NewPostSessionShareRequest calls the generic PostSessionShare builder with application/json body
- func NewPostSessionShareRequest(server string, body PostSessionShareJSONRequestBody) (*http.Request, error) {
- var bodyReader io.Reader
- buf, err := json.Marshal(body)
- if err != nil {
- return nil, err
- }
- bodyReader = bytes.NewReader(buf)
- return NewPostSessionShareRequestWithBody(server, "application/json", bodyReader)
- }
- // NewPostSessionShareRequestWithBody generates requests for PostSessionShare with any type of body
- func NewPostSessionShareRequestWithBody(server string, contentType string, body io.Reader) (*http.Request, error) {
- var err error
- serverURL, err := url.Parse(server)
- if err != nil {
- return nil, err
- }
- operationPath := fmt.Sprintf("/session_share")
- if operationPath[0] == '/' {
- operationPath = "." + operationPath
- }
- queryURL, err := serverURL.Parse(operationPath)
- if err != nil {
- return nil, err
- }
- req, err := http.NewRequest("POST", queryURL.String(), body)
- if err != nil {
- return nil, err
- }
- req.Header.Add("Content-Type", contentType)
- return req, nil
- }
- // NewPostSessionSummarizeRequest calls the generic PostSessionSummarize builder with application/json body
- func NewPostSessionSummarizeRequest(server string, body PostSessionSummarizeJSONRequestBody) (*http.Request, error) {
- var bodyReader io.Reader
- buf, err := json.Marshal(body)
- if err != nil {
- return nil, err
- }
- bodyReader = bytes.NewReader(buf)
- return NewPostSessionSummarizeRequestWithBody(server, "application/json", bodyReader)
- }
- // NewPostSessionSummarizeRequestWithBody generates requests for PostSessionSummarize with any type of body
- func NewPostSessionSummarizeRequestWithBody(server string, contentType string, body io.Reader) (*http.Request, error) {
- var err error
- serverURL, err := url.Parse(server)
- if err != nil {
- return nil, err
- }
- operationPath := fmt.Sprintf("/session_summarize")
- if operationPath[0] == '/' {
- operationPath = "." + operationPath
- }
- queryURL, err := serverURL.Parse(operationPath)
- if err != nil {
- return nil, err
- }
- req, err := http.NewRequest("POST", queryURL.String(), body)
- if err != nil {
- return nil, err
- }
- req.Header.Add("Content-Type", contentType)
- return req, nil
- }
- func (c *Client) applyEditors(ctx context.Context, req *http.Request, additionalEditors []RequestEditorFn) error {
- for _, r := range c.RequestEditors {
- if err := r(ctx, req); err != nil {
- return err
- }
- }
- for _, r := range additionalEditors {
- if err := r(ctx, req); err != nil {
- return err
- }
- }
- return nil
- }
- // ClientWithResponses builds on ClientInterface to offer response payloads
- type ClientWithResponses struct {
- ClientInterface
- }
- // NewClientWithResponses creates a new ClientWithResponses, which wraps
- // Client with return type handling
- func NewClientWithResponses(server string, opts ...ClientOption) (*ClientWithResponses, error) {
- client, err := NewClient(server, opts...)
- if err != nil {
- return nil, err
- }
- return &ClientWithResponses{client}, nil
- }
- // WithBaseURL overrides the baseURL.
- func WithBaseURL(baseURL string) ClientOption {
- return func(c *Client) error {
- newBaseURL, err := url.Parse(baseURL)
- if err != nil {
- return err
- }
- c.Server = newBaseURL.String()
- return nil
- }
- }
- // ClientWithResponsesInterface is the interface specification for the client with responses above.
- type ClientWithResponsesInterface interface {
- // GetEventWithResponse request
- GetEventWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*GetEventResponse, error)
- // PostProviderListWithResponse request
- PostProviderListWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*PostProviderListResponse, error)
- // PostSessionAbortWithBodyWithResponse request with any body
- PostSessionAbortWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*PostSessionAbortResponse, error)
- PostSessionAbortWithResponse(ctx context.Context, body PostSessionAbortJSONRequestBody, reqEditors ...RequestEditorFn) (*PostSessionAbortResponse, error)
- // PostSessionChatWithBodyWithResponse request with any body
- PostSessionChatWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*PostSessionChatResponse, error)
- PostSessionChatWithResponse(ctx context.Context, body PostSessionChatJSONRequestBody, reqEditors ...RequestEditorFn) (*PostSessionChatResponse, error)
- // PostSessionCreateWithResponse request
- PostSessionCreateWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*PostSessionCreateResponse, error)
- // PostSessionListWithResponse request
- PostSessionListWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*PostSessionListResponse, error)
- // PostSessionMessagesWithBodyWithResponse request with any body
- PostSessionMessagesWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*PostSessionMessagesResponse, error)
- PostSessionMessagesWithResponse(ctx context.Context, body PostSessionMessagesJSONRequestBody, reqEditors ...RequestEditorFn) (*PostSessionMessagesResponse, error)
- // PostSessionShareWithBodyWithResponse request with any body
- PostSessionShareWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*PostSessionShareResponse, error)
- PostSessionShareWithResponse(ctx context.Context, body PostSessionShareJSONRequestBody, reqEditors ...RequestEditorFn) (*PostSessionShareResponse, error)
- // PostSessionSummarizeWithBodyWithResponse request with any body
- PostSessionSummarizeWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*PostSessionSummarizeResponse, error)
- PostSessionSummarizeWithResponse(ctx context.Context, body PostSessionSummarizeJSONRequestBody, reqEditors ...RequestEditorFn) (*PostSessionSummarizeResponse, error)
- }
- type GetEventResponse struct {
- Body []byte
- HTTPResponse *http.Response
- JSON200 *Event
- }
- // Status returns HTTPResponse.Status
- func (r GetEventResponse) Status() string {
- if r.HTTPResponse != nil {
- return r.HTTPResponse.Status
- }
- return http.StatusText(0)
- }
- // StatusCode returns HTTPResponse.StatusCode
- func (r GetEventResponse) StatusCode() int {
- if r.HTTPResponse != nil {
- return r.HTTPResponse.StatusCode
- }
- return 0
- }
- type PostProviderListResponse struct {
- Body []byte
- HTTPResponse *http.Response
- JSON200 *[]ProviderInfo
- }
- // Status returns HTTPResponse.Status
- func (r PostProviderListResponse) Status() string {
- if r.HTTPResponse != nil {
- return r.HTTPResponse.Status
- }
- return http.StatusText(0)
- }
- // StatusCode returns HTTPResponse.StatusCode
- func (r PostProviderListResponse) StatusCode() int {
- if r.HTTPResponse != nil {
- return r.HTTPResponse.StatusCode
- }
- return 0
- }
- type PostSessionAbortResponse struct {
- Body []byte
- HTTPResponse *http.Response
- JSON200 *bool
- }
- // Status returns HTTPResponse.Status
- func (r PostSessionAbortResponse) Status() string {
- if r.HTTPResponse != nil {
- return r.HTTPResponse.Status
- }
- return http.StatusText(0)
- }
- // StatusCode returns HTTPResponse.StatusCode
- func (r PostSessionAbortResponse) StatusCode() int {
- if r.HTTPResponse != nil {
- return r.HTTPResponse.StatusCode
- }
- return 0
- }
- type PostSessionChatResponse struct {
- Body []byte
- HTTPResponse *http.Response
- JSON200 *MessageInfo
- }
- // Status returns HTTPResponse.Status
- func (r PostSessionChatResponse) Status() string {
- if r.HTTPResponse != nil {
- return r.HTTPResponse.Status
- }
- return http.StatusText(0)
- }
- // StatusCode returns HTTPResponse.StatusCode
- func (r PostSessionChatResponse) StatusCode() int {
- if r.HTTPResponse != nil {
- return r.HTTPResponse.StatusCode
- }
- return 0
- }
- type PostSessionCreateResponse struct {
- Body []byte
- HTTPResponse *http.Response
- JSON200 *SessionInfo
- }
- // Status returns HTTPResponse.Status
- func (r PostSessionCreateResponse) Status() string {
- if r.HTTPResponse != nil {
- return r.HTTPResponse.Status
- }
- return http.StatusText(0)
- }
- // StatusCode returns HTTPResponse.StatusCode
- func (r PostSessionCreateResponse) StatusCode() int {
- if r.HTTPResponse != nil {
- return r.HTTPResponse.StatusCode
- }
- return 0
- }
- type PostSessionListResponse struct {
- Body []byte
- HTTPResponse *http.Response
- JSON200 *[]SessionInfo
- }
- // Status returns HTTPResponse.Status
- func (r PostSessionListResponse) Status() string {
- if r.HTTPResponse != nil {
- return r.HTTPResponse.Status
- }
- return http.StatusText(0)
- }
- // StatusCode returns HTTPResponse.StatusCode
- func (r PostSessionListResponse) StatusCode() int {
- if r.HTTPResponse != nil {
- return r.HTTPResponse.StatusCode
- }
- return 0
- }
- type PostSessionMessagesResponse struct {
- Body []byte
- HTTPResponse *http.Response
- JSON200 *[]MessageInfo
- }
- // Status returns HTTPResponse.Status
- func (r PostSessionMessagesResponse) Status() string {
- if r.HTTPResponse != nil {
- return r.HTTPResponse.Status
- }
- return http.StatusText(0)
- }
- // StatusCode returns HTTPResponse.StatusCode
- func (r PostSessionMessagesResponse) StatusCode() int {
- if r.HTTPResponse != nil {
- return r.HTTPResponse.StatusCode
- }
- return 0
- }
- type PostSessionShareResponse struct {
- Body []byte
- HTTPResponse *http.Response
- JSON200 *SessionInfo
- }
- // Status returns HTTPResponse.Status
- func (r PostSessionShareResponse) Status() string {
- if r.HTTPResponse != nil {
- return r.HTTPResponse.Status
- }
- return http.StatusText(0)
- }
- // StatusCode returns HTTPResponse.StatusCode
- func (r PostSessionShareResponse) StatusCode() int {
- if r.HTTPResponse != nil {
- return r.HTTPResponse.StatusCode
- }
- return 0
- }
- type PostSessionSummarizeResponse struct {
- Body []byte
- HTTPResponse *http.Response
- JSON200 *bool
- }
- // Status returns HTTPResponse.Status
- func (r PostSessionSummarizeResponse) Status() string {
- if r.HTTPResponse != nil {
- return r.HTTPResponse.Status
- }
- return http.StatusText(0)
- }
- // StatusCode returns HTTPResponse.StatusCode
- func (r PostSessionSummarizeResponse) StatusCode() int {
- if r.HTTPResponse != nil {
- return r.HTTPResponse.StatusCode
- }
- return 0
- }
- // GetEventWithResponse request returning *GetEventResponse
- func (c *ClientWithResponses) GetEventWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*GetEventResponse, error) {
- rsp, err := c.GetEvent(ctx, reqEditors...)
- if err != nil {
- return nil, err
- }
- return ParseGetEventResponse(rsp)
- }
- // PostProviderListWithResponse request returning *PostProviderListResponse
- func (c *ClientWithResponses) PostProviderListWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*PostProviderListResponse, error) {
- rsp, err := c.PostProviderList(ctx, reqEditors...)
- if err != nil {
- return nil, err
- }
- return ParsePostProviderListResponse(rsp)
- }
- // PostSessionAbortWithBodyWithResponse request with arbitrary body returning *PostSessionAbortResponse
- func (c *ClientWithResponses) PostSessionAbortWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*PostSessionAbortResponse, error) {
- rsp, err := c.PostSessionAbortWithBody(ctx, contentType, body, reqEditors...)
- if err != nil {
- return nil, err
- }
- return ParsePostSessionAbortResponse(rsp)
- }
- func (c *ClientWithResponses) PostSessionAbortWithResponse(ctx context.Context, body PostSessionAbortJSONRequestBody, reqEditors ...RequestEditorFn) (*PostSessionAbortResponse, error) {
- rsp, err := c.PostSessionAbort(ctx, body, reqEditors...)
- if err != nil {
- return nil, err
- }
- return ParsePostSessionAbortResponse(rsp)
- }
- // PostSessionChatWithBodyWithResponse request with arbitrary body returning *PostSessionChatResponse
- func (c *ClientWithResponses) PostSessionChatWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*PostSessionChatResponse, error) {
- rsp, err := c.PostSessionChatWithBody(ctx, contentType, body, reqEditors...)
- if err != nil {
- return nil, err
- }
- return ParsePostSessionChatResponse(rsp)
- }
- func (c *ClientWithResponses) PostSessionChatWithResponse(ctx context.Context, body PostSessionChatJSONRequestBody, reqEditors ...RequestEditorFn) (*PostSessionChatResponse, error) {
- rsp, err := c.PostSessionChat(ctx, body, reqEditors...)
- if err != nil {
- return nil, err
- }
- return ParsePostSessionChatResponse(rsp)
- }
- // PostSessionCreateWithResponse request returning *PostSessionCreateResponse
- func (c *ClientWithResponses) PostSessionCreateWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*PostSessionCreateResponse, error) {
- rsp, err := c.PostSessionCreate(ctx, reqEditors...)
- if err != nil {
- return nil, err
- }
- return ParsePostSessionCreateResponse(rsp)
- }
- // PostSessionListWithResponse request returning *PostSessionListResponse
- func (c *ClientWithResponses) PostSessionListWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*PostSessionListResponse, error) {
- rsp, err := c.PostSessionList(ctx, reqEditors...)
- if err != nil {
- return nil, err
- }
- return ParsePostSessionListResponse(rsp)
- }
- // PostSessionMessagesWithBodyWithResponse request with arbitrary body returning *PostSessionMessagesResponse
- func (c *ClientWithResponses) PostSessionMessagesWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*PostSessionMessagesResponse, error) {
- rsp, err := c.PostSessionMessagesWithBody(ctx, contentType, body, reqEditors...)
- if err != nil {
- return nil, err
- }
- return ParsePostSessionMessagesResponse(rsp)
- }
- func (c *ClientWithResponses) PostSessionMessagesWithResponse(ctx context.Context, body PostSessionMessagesJSONRequestBody, reqEditors ...RequestEditorFn) (*PostSessionMessagesResponse, error) {
- rsp, err := c.PostSessionMessages(ctx, body, reqEditors...)
- if err != nil {
- return nil, err
- }
- return ParsePostSessionMessagesResponse(rsp)
- }
- // PostSessionShareWithBodyWithResponse request with arbitrary body returning *PostSessionShareResponse
- func (c *ClientWithResponses) PostSessionShareWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*PostSessionShareResponse, error) {
- rsp, err := c.PostSessionShareWithBody(ctx, contentType, body, reqEditors...)
- if err != nil {
- return nil, err
- }
- return ParsePostSessionShareResponse(rsp)
- }
- func (c *ClientWithResponses) PostSessionShareWithResponse(ctx context.Context, body PostSessionShareJSONRequestBody, reqEditors ...RequestEditorFn) (*PostSessionShareResponse, error) {
- rsp, err := c.PostSessionShare(ctx, body, reqEditors...)
- if err != nil {
- return nil, err
- }
- return ParsePostSessionShareResponse(rsp)
- }
- // PostSessionSummarizeWithBodyWithResponse request with arbitrary body returning *PostSessionSummarizeResponse
- func (c *ClientWithResponses) PostSessionSummarizeWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*PostSessionSummarizeResponse, error) {
- rsp, err := c.PostSessionSummarizeWithBody(ctx, contentType, body, reqEditors...)
- if err != nil {
- return nil, err
- }
- return ParsePostSessionSummarizeResponse(rsp)
- }
- func (c *ClientWithResponses) PostSessionSummarizeWithResponse(ctx context.Context, body PostSessionSummarizeJSONRequestBody, reqEditors ...RequestEditorFn) (*PostSessionSummarizeResponse, error) {
- rsp, err := c.PostSessionSummarize(ctx, body, reqEditors...)
- if err != nil {
- return nil, err
- }
- return ParsePostSessionSummarizeResponse(rsp)
- }
- // ParseGetEventResponse parses an HTTP response from a GetEventWithResponse call
- func ParseGetEventResponse(rsp *http.Response) (*GetEventResponse, error) {
- bodyBytes, err := io.ReadAll(rsp.Body)
- defer func() { _ = rsp.Body.Close() }()
- if err != nil {
- return nil, err
- }
- response := &GetEventResponse{
- Body: bodyBytes,
- HTTPResponse: rsp,
- }
- switch {
- case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200:
- var dest Event
- if err := json.Unmarshal(bodyBytes, &dest); err != nil {
- return nil, err
- }
- response.JSON200 = &dest
- }
- return response, nil
- }
- // ParsePostProviderListResponse parses an HTTP response from a PostProviderListWithResponse call
- func ParsePostProviderListResponse(rsp *http.Response) (*PostProviderListResponse, error) {
- bodyBytes, err := io.ReadAll(rsp.Body)
- defer func() { _ = rsp.Body.Close() }()
- if err != nil {
- return nil, err
- }
- response := &PostProviderListResponse{
- Body: bodyBytes,
- HTTPResponse: rsp,
- }
- switch {
- case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200:
- var dest []ProviderInfo
- if err := json.Unmarshal(bodyBytes, &dest); err != nil {
- return nil, err
- }
- response.JSON200 = &dest
- }
- return response, nil
- }
- // ParsePostSessionAbortResponse parses an HTTP response from a PostSessionAbortWithResponse call
- func ParsePostSessionAbortResponse(rsp *http.Response) (*PostSessionAbortResponse, error) {
- bodyBytes, err := io.ReadAll(rsp.Body)
- defer func() { _ = rsp.Body.Close() }()
- if err != nil {
- return nil, err
- }
- response := &PostSessionAbortResponse{
- Body: bodyBytes,
- HTTPResponse: rsp,
- }
- switch {
- case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200:
- var dest bool
- if err := json.Unmarshal(bodyBytes, &dest); err != nil {
- return nil, err
- }
- response.JSON200 = &dest
- }
- return response, nil
- }
- // ParsePostSessionChatResponse parses an HTTP response from a PostSessionChatWithResponse call
- func ParsePostSessionChatResponse(rsp *http.Response) (*PostSessionChatResponse, error) {
- bodyBytes, err := io.ReadAll(rsp.Body)
- defer func() { _ = rsp.Body.Close() }()
- if err != nil {
- return nil, err
- }
- response := &PostSessionChatResponse{
- Body: bodyBytes,
- HTTPResponse: rsp,
- }
- switch {
- case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200:
- var dest MessageInfo
- if err := json.Unmarshal(bodyBytes, &dest); err != nil {
- return nil, err
- }
- response.JSON200 = &dest
- }
- return response, nil
- }
- // ParsePostSessionCreateResponse parses an HTTP response from a PostSessionCreateWithResponse call
- func ParsePostSessionCreateResponse(rsp *http.Response) (*PostSessionCreateResponse, error) {
- bodyBytes, err := io.ReadAll(rsp.Body)
- defer func() { _ = rsp.Body.Close() }()
- if err != nil {
- return nil, err
- }
- response := &PostSessionCreateResponse{
- Body: bodyBytes,
- HTTPResponse: rsp,
- }
- switch {
- case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200:
- var dest SessionInfo
- if err := json.Unmarshal(bodyBytes, &dest); err != nil {
- return nil, err
- }
- response.JSON200 = &dest
- }
- return response, nil
- }
- // ParsePostSessionListResponse parses an HTTP response from a PostSessionListWithResponse call
- func ParsePostSessionListResponse(rsp *http.Response) (*PostSessionListResponse, error) {
- bodyBytes, err := io.ReadAll(rsp.Body)
- defer func() { _ = rsp.Body.Close() }()
- if err != nil {
- return nil, err
- }
- response := &PostSessionListResponse{
- Body: bodyBytes,
- HTTPResponse: rsp,
- }
- switch {
- case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200:
- var dest []SessionInfo
- if err := json.Unmarshal(bodyBytes, &dest); err != nil {
- return nil, err
- }
- response.JSON200 = &dest
- }
- return response, nil
- }
- // ParsePostSessionMessagesResponse parses an HTTP response from a PostSessionMessagesWithResponse call
- func ParsePostSessionMessagesResponse(rsp *http.Response) (*PostSessionMessagesResponse, error) {
- bodyBytes, err := io.ReadAll(rsp.Body)
- defer func() { _ = rsp.Body.Close() }()
- if err != nil {
- return nil, err
- }
- response := &PostSessionMessagesResponse{
- Body: bodyBytes,
- HTTPResponse: rsp,
- }
- switch {
- case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200:
- var dest []MessageInfo
- if err := json.Unmarshal(bodyBytes, &dest); err != nil {
- return nil, err
- }
- response.JSON200 = &dest
- }
- return response, nil
- }
- // ParsePostSessionShareResponse parses an HTTP response from a PostSessionShareWithResponse call
- func ParsePostSessionShareResponse(rsp *http.Response) (*PostSessionShareResponse, error) {
- bodyBytes, err := io.ReadAll(rsp.Body)
- defer func() { _ = rsp.Body.Close() }()
- if err != nil {
- return nil, err
- }
- response := &PostSessionShareResponse{
- Body: bodyBytes,
- HTTPResponse: rsp,
- }
- switch {
- case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200:
- var dest SessionInfo
- if err := json.Unmarshal(bodyBytes, &dest); err != nil {
- return nil, err
- }
- response.JSON200 = &dest
- }
- return response, nil
- }
- // ParsePostSessionSummarizeResponse parses an HTTP response from a PostSessionSummarizeWithResponse call
- func ParsePostSessionSummarizeResponse(rsp *http.Response) (*PostSessionSummarizeResponse, error) {
- bodyBytes, err := io.ReadAll(rsp.Body)
- defer func() { _ = rsp.Body.Close() }()
- if err != nil {
- return nil, err
- }
- response := &PostSessionSummarizeResponse{
- Body: bodyBytes,
- HTTPResponse: rsp,
- }
- switch {
- case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200:
- var dest bool
- if err := json.Unmarshal(bodyBytes, &dest); err != nil {
- return nil, err
- }
- response.JSON200 = &dest
- }
- return response, nil
- }
|